The entire point of interfaces is to give you the flexibility to have your class be forced to implement multiple interfaces, but still not allow multiple inheritance. The issues with inheriting from multiple classes are many and varied and the wikipedia page on it sums them up pretty well.
Interfaces are a compromise. Most of the problems with multiple inheritance don't apply to abstract base classes, so most modern languages these days disable multiple inheritance yet call abstract base classes interfaces and allows a class to "implement" as many of those as they want.
Answer from Craig H on Stack Overflowoop - What is the point of interfaces in PHP? - Stack Overflow
Composercat - Graphical User Interface for Composer
Interface Vue to a PHP MVC framework?
In the case of an API, the front end and back end (in an ideal world) are completely separated. The only interaction between them would be through REST endpoints, and which backend you use would be irrelevant to Vue.
That said, my personal favorite tool for building the API is Laravel. Laravel has route shortcuts that automatically generate REST routes for a model. For instance with a Post model, it would create routes to fetch the posts, edit a post, create a new post, etc.
Then on the front end I use vue-resource to create resources that have the same routes as my Laravel API. so in JS I would run posts.update({id: 1}, {title: "New Title"});. Since both vue-resource and Laravel use REST practices, the routes match up perfectly.
Here is an example of a Laravel REST controller. It has update, store, delete, show, and index routes. https://github.com/jsiebach/angular-todo/blob/master/app/Http/Controllers/TodoController.php
In Vue then you would just create a resource to call those using var todos = Vue.http.resource("/api/todos/:id") and it maps to the same routes. todos.delete({id: 1}) for example. Vue resources: https://github.com/vuejs/vue-resource/blob/master/docs/resource.md
Any reason to use an interface over an abstract class?
Videos
Hi everyone.
I read some documentation about PHP Interfaces, but I still don't understand their usefulness. It talks about contracts with classes but what is a contract ?
As I understand them right now, they seem to describe functions that a class should absolutely have.
At first I though you had to write functions in the interface so they can be easily reusable between classes, but it appears that the core of the function is written in the class...
Please enlight me what is the point in this because I'm in the dark. It would be even better if you have a pertinent example to show me !
Thanks
The entire point of interfaces is to give you the flexibility to have your class be forced to implement multiple interfaces, but still not allow multiple inheritance. The issues with inheriting from multiple classes are many and varied and the wikipedia page on it sums them up pretty well.
Interfaces are a compromise. Most of the problems with multiple inheritance don't apply to abstract base classes, so most modern languages these days disable multiple inheritance yet call abstract base classes interfaces and allows a class to "implement" as many of those as they want.
The concept is useful all around in object oriented programming. To me I think of an interface as a contract. So long my class and your class agree on this method signature contract we can "interface". As for abstract classes those I see as more of base classes that stub out some methods and I need to fill in the details.