Contents:
- Description
- Development goals
- Incoming task
- Install
- Frontend form
- Backend structure
- Extension
- Tests
- A similar example based on Symfony
Framework-independent API example based on Laravel.
Development goals – to demonstrate how applications can be built without being tied to a specific framework.
-
Install composer
composer install. -
Create
.env- make a copy from .env.example. -
Docker install:
vendor/bin/sail build vendor/bin/sail up -d
-
App install:
vendor/bin/sail shell php artisan migrate --seed php artisan key:generate
-
Check - localhost
Visit home page and use a form to check the api.
Request User Response
| /\
Post Form | | Json object (status & data)
multipart/form-data| |
\/ |
Laravel
\/ /\
Http Controller
| /\
Calculate command | | View Dto
| |
\/ |
Carrier Service
| /\
Find via VO Slug | | Carrier
\/ |
Carrier Repository
/\
Use Mysql |
as data |
container |
\/
Mysql
You can extend the aplication by:
- adding a new carrier
- changing the storage
- Implement a new calculate class in the dir
- Add a new row to the
carriersmysql table:- name
- slug
- classname (from #1)
- created_at
If you would like to use config, file storage, or another persistence method, you only need to replace the repository to extend the application.
The Carrier service depends on the repository interface.
- Create a new repository
- Register it the app provider
All classes are covered by tests. You can use php artisan test to run tests inside a container. Also check test dir.
You can check a similar example based on Symfony here.
Differences:
| layer | this app | symfony example |
|---|---|---|
| controller | laravel | symfony |
| storage | mysql | config |
| template | blade | twig |