Challenge: you need a flexible (swap in other repository implementations) way to display some kind of resource. Let's say, Posts. What does your folder structure look like?
Requirements:
- Repository implements an interface
- Must show at least one implementation of the interface (Eloquent version is fine)
- The interface is injected into your PostsController.
- Show where you register your IoC bindings
- Show folder structure. Where are interfaces/repositories stored?
/app/controllers/PostsController.php
I will have an api package:
/src/Example/Api/Models/Post.php
/src/Example/Api/Repositories/PostInterface.php
/src/Example/Api/Repositories/EloquentPostRepository.php (or namespaced Post/Eloquent.php)
/src/Example/Api/ApiServiceProvider.php
I have to figure out how to develop this easily. Actually I'm doing it on a workbench but it's a nightmare when you switch to the
composer.json
package... I'm not sure how to handle this, thinking on best options too.