This is a package who gives flexible way to build a structure of the Porto (Software Architectural Pattern) in your Laravel project. You should no longer to migrate a lot of files and folders handle.
This package will do the job for you in some clicks.
- Introduction
- How to install?
- Ship structure
- Containers
- Laravel console commands
- Make
- make:cast
- make:channel
- make:command
- make:component
- make:controller
- make:enum
- make:event
- make:exception
- make:factory
- make:job
- make:listener
- make:mail
- make:middleware
- make:model
- make:notification
- make:observer
- make:policy
- make:provider
- make:request
- make:resource
- make:rule
- make:scope
- make:seeder
- make:test
- Model
- Make
- Additional console commands
Laravel is a popular and beautiful PHP framework who helps a lot to make your web applications. But web applications tend to grow and become harder to maintain and optimize. Unfortunately, Laravel, like other frameworks, does not have standard tools that allow you to write flexible, readable and easily maintainable code.
Porto (Software Architectural Pattern) is a brilliant solution for building large applications. This pattern helps you and your team to organize and maintain your code.
You can find more information about Porto by this link: https://github.com/Mahmoudz/Porto
-
First of all you need to install the package:
composer require iadewunmi/laravel-porto-sap
-
Next, you need to enable installed package in your .env file:
PORTO_SAP_ENABLED=true
-
Next, you can install porto structure using this command:
php artisan porto:install --container=<Container Name> --container-<Container Type>
You need to put directory path when the Porto structure will be installed or you can confirm installation in the default app/ directory.
Of course, if you put the custom directory path, you need to set it in the autoload -> psr-4 in the composer.json file.
You also can add directory name of your first container. For example:
--container=<Container Name>
This container will be installed in the Containers directory with standard structure. You also can force another container structures like:
--container-default --container-api --container-cli --container-web --container-full
-
Next, you need to put some changes in the bootstrap/app.php file.
From:
return [ App\Providers\AppServiceProvider::class, ];
-
That's all.
Below you can find the skeleton structure of ship, each type of containers and information about adapted laravel console commands.
This is a skeleton of the installed Ship structure.
Ship
├── Abstracts
│ ├── Broadcasting
│ │ ├── Channel.php
│ │ ├── PresenceChannel.php
│ │ └── PrivateChannel.php
│ │── Commands
│ │ └── ConsoleCommand.php
│ ├── Components
│ │ └── Component.php
│ ├── Controllers
│ │ └── Controller.php
│ ├── Events
│ │ └── Event.php
│ ├── Exceptions
│ │ └── Handler.php
│ ├── Factories
│ │ └── Factory.php
│ ├── Jobs
│ │ └── Job.php
│ ├── Mails
│ │ ├── Mailables
│ │ │ ├── Content.php
│ │ │ └── Envelope.php
│ │ └── Mailable.php
│ ├── Middleware
│ │ ├── Authenticate.php
│ │ ├── EncryptCookies.php
│ │ ├── PreventRequestsDuringMaintenance.php
│ │ ├── TrimStrings.php
│ │ ├── TrustHosts.php
│ │ ├── TrustProxies.php
│ │ ├── ValidateSignature.php
│ │ └── VerifyCsrfToken.php
│ ├── Models
│ │ ├── BaseModel.php
│ │ ├── UserModel.php
│ │ ├── Pivot.php
│ │ ├── MorphPivot.php
│ │ └── Builder.php
│ ├── Notifications
│ │ ├── Messages
│ │ │ └── MailMessage.php
│ │ └── Notification.php
│ ├── Policies
│ │ └── Policy.php
│ ├── Providers
│ │ ├── AuthServiceProvider.php
│ │ ├── ServiceProvider.php
│ │ ├── EventServiceProvider.php
│ │ └── RouteServiceProvider.php
│ ├── Requests
│ │ ├── Request.php
│ │ └── FormRequest.php
│ ├── Responses
│ │ ├── Response.php
│ │ ├── RedirectResponse.php
│ │ └── JsonResource.php
│ ├── Resources
│ │ └── ResourceCollection.php
│ ├── Seeders
│ │ └── Seeder.php
│ ├── Tests
│ │ └── PhpUnit
│ │ └── TestCase.php
│ ├── Translations
│ │ └── PotentiallyTranslatedString.php
│ └── Views
│ └── Component.php
├── Broadcasting
│ ├── Channel.php
│ ├── PresenceChannel.php
│ └── PrivateChannel.php
├── Commands
├── Configs
├── Controllers
│ └── Controller.php
├── Events
│ └── Event.php
├── Exceptions
│ └── Handler.php
├── Helpers
│ └── helper.php
├── Kernels
│ ├── ConsoleKernel.php
│ └── HttpKernel.php
├── Mails
│ └── Mailables
│ ├── Envelope.php
│ └── Content.php
├── Middleware
│ ├── Authenticate.php
│ ├── EncryptCookies.php
│ ├── PreventRequestsDuringMaintenance.php
│ ├── RedirectIfAuthenticated.php
│ ├── TrimStrings.php
│ ├── TrustHosts.php
│ ├── TrustProxies.php
│ ├── ValidateSignature.php
│ └── VerifyCsrfToken.php
├── Migrations
├── Models
│ ├── Model.php
│ ├── UserModel.php
│ ├── Pivot.php
│ ├── MorphPivot.php
│ ├── Builder.php
│ └── Scope.php
├── Notifications
│ ├── Messages
│ │ └── MailMessage.php
│ └── Notification.php
├── Policies
│ └── Policy.php
├── Providers
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Requests
│ ├── Request.php
│ └── FormRequest.php
├── Responses
│ ├── Response.php
│ └── RedirectResponse.php
├── Resources
│ ├── JsonResource.php
│ └── ResourceCollection.php
├── Seeders
├── Tests
│ └── TestCase.php
├── Traits
│ └── CreatesApplication.php
└── Translations
To create container with necessary files and folders you need to put this command:
php artisan make:container <Name>
Without forced container type will be created standard container structure.
Container
├── Actions
├── Tasks
├── Models
├── Loaders
│ ├── AliasesLoader.php
│ ├── ProvidersLoader.php
│ └── MiddlewareLoader.php
└── UI
├── WEB
│ ├── Routes
│ ├── Controllers
│ └── Views
├── API
│ ├── Routes
│ ├── Controllers
│ └── Transformers
└── CLI
├── Routes
└── Commands
To create container with default route, controller, view and test file you can via command below:
php artisan make:container <Name> --default
Container
├── Actions
├── Tasks
├── Models
├── Loaders
│ ├── AliasesLoader.php
│ ├── ProvidersLoader.php
│ └── MiddlewareLoader.php
└── UI
├── WEB
│ ├── Routes
│ │ ├── home.php
│ ├── Controllers
│ │ ├── HomeController.php
│ ├── Views
│ │ ├── home.blade.php
│ ├── Tests
│ │ ├── Functional
│ └── └── └── ExampleTest.php
├── API
│ ├── Routes
│ ├── Controllers
│ └── Transformers
└── CLI
├── Routes
└── Commands
To create container only for API needles you can via command below:
php artisan make:container <Name> --api
Container
├── Actions
├── Tasks
├── Models
├── Loaders
│ ├── AliasesLoader.php
│ ├── ProvidersLoader.php
│ └── MiddlewareLoader.php
└── UI
└── API
├── Routes
├── Controllers
└── Transformers
To create container only for command line interface needles you can via command below:
php artisan make:container <Name> --cli
Container
├── Actions
├── Tasks
├── Models
├── Loaders
│ ├── AliasesLoader.php
│ ├── ProvidersLoader.php
│ └── MiddlewareLoader.php
└── UI
└── CLI
├── Routes
└── Commands
To create container only for web needles you can via command below:
php artisan make:container <Name> --web
Container
├── Actions
├── Tasks
├── Models
├── Loaders
│ ├── AliasesLoader.php
│ ├── ProvidersLoader.php
│ └── MiddlewareLoader.php
└── UI
└── WEB
├── Routes
├── Controllers
└── Views
To create container with full structure you can via command below:
php artisan make:container <Name> --full
Container
├── Actions
├── Tasks
├── Models
├── Values
├── Events
├── Listeners
├── Policies
├── Exceptions
├── Contracts
├── Traits
├── Enums
├── Jobs
├── Notifications
├── Providers
├── Configs
├── Loaders
│ ├── AliasesLoader.php
│ ├── ProvidersLoader.php
│ └── MiddlewareLoader.php
├── Mails
│ └── Templates
├── Data
│ ├── Migrations
│ ├── Seeders
│ ├── Factories
│ ├── Criteria
│ ├── Repositories
│ ├── Validators
│ ├── Transporters
│ └── Rules
├── Tests
│ ├── Traits
│ └── Unit
└── UI
├── WEB
│ ├── Routes
│ ├── Controllers
│ ├── Requests
│ ├── Tests
│ │ └── Functional
│ └── Views
├── API
│ ├── Routes
│ ├── Controllers
│ ├── Requests
│ ├── Tests
│ │ └── Functional
│ └── Transformers
└── CLI
├── Routes
├── Commands
└── Tests
└── Functional
This is a list of adapted laravel console commands for the Porto.
Without container name some commands will be created class in the Ship.
Other commands require the container name
php artisan make:cast <Name> --container=<Container Name>
php artisan make:channel <Name> --container=<Container Name>
php artisan make:command <Name>
php artisan make:command <Name> --container=<Container Name>
php artisan make:component <Name> --container=<Container Name>
php artisan make:controller <Name> --container=<Container Name>
php artisan make:enum <Name> --container=<Container Name>
php artisan make:event <Name>
php artisan make:event <Name> --container=<Container Name>
php artisan make:exception <Name>
php artisan make:exception <Name> --container=<Container Name>
php artisan make:factory <Name> --container=<Container Name>
php artisan make:job <Name>
php artisan make:job <Name> --container=<Container Name>
php artisan make:listener <Name> --container=<Container Name>
php artisan make:mail <Name>
php artisan make:mail <Name> --container=<Container Name>
php artisan make:middleware <Name>
php artisan make:middleware <Name> --container=<Container Name>
php artisan make:model <Name> --container=<Container Name>
php artisan make:notification <Name>
php artisan make:notification <Name> --container=<Container Name>
php artisan make:observer <Name> --container=<Container Name>
php artisan make:policy <Name> --container=<Container Name>
php artisan make:provider <Name>
php artisan make:provider <Name> --container=<Container Name>
php artisan make:request <Name> --container=<Container Name> --uiType=api
php artisan make:request <Name> --container=<Container Name> --uiType=web
php artisan make:resource <Name> --container=<Container Name>
php artisan make:rule <Name> --container=<Container Name>
php artisan make:scope <Name> --container=<Container Name>
php artisan make:seeder <Name>
php artisan make:seeder <Name> --container=<Container Name>
php artisan make:test <Name> --container=<Container Name> --uiType=api
php artisan make:test <Name> --container=<Container Name> --uiType=cli
php artisan make:test <Name> --container=<Container Name> --uiType=web
php artisan make:show --container=<Container Name>
This is a list of console commands for the Porto who does not exists in Laravel.
Without container name some commands will be created class in the Ship.
Other commands require the container name
php artisan make:action <Name> --container=<Container Name>
php artisan make:config <Name>
php artisan make:config <Name> --container=<Container Name>
php artisan make:contract <Name> --container=<Container Name>
php artisan make:helper <Name>
php artisan make:repository <Name>
php artisan make:task <Name> --container=<Container Name>
php artisan make:trait <Name> --container=<Container Name>
php artisan make:trait <Name> --container=<Container Name> --test
php artisan make:translation <Name> --lang=<lang code>
php artisan make:value <Name> --container=<Container Name>
Released under the MIT License, see LICENSE.