First of all let's clone the project:
git clone [email protected]:leo98barros/talk-srp-laravel.git
With composer and PHP ^8.1 configured on your machine:
composer install
If the installation has not copied the env.example file, copy it and rename it to .env only and run:
php artisan key:generate
Here I am using SQLITE to make the database configuration easier, but to make this possible
- Create a database.sqlite file inside the database folder;
- Paste the absolute path in the .env file under the DB_DATABASE key;
- Lastly run:
php artisan migrate
The idea of the project is to show how an example of folders would look if the Repository and Service patterns were implemented. Both are independent of each other, but the proposal here is to use them together. These diagrams represent what is being proposed here:
- MVC architecture:
- Service & Repository Pattern:
- MVC + SRP (Service & Repository Pattern):
- Folder layout: