Recommend this page to a friend! |
Classes of Leonardo Di Sarli | Ala PHP API Micro-Framework | README.md | Download |
|
DownloadLumen ALAAPI Rest based in lumen using query builder that auto generate base code for simple crud (with automatic generated 100% unit and feature tests). Release 7.0.0 Requires PHP 8.3 Release 6.0.0 Requires PHP 8.2 Release 5.0.0 Requires PHP 8.1 Release 4.0.0 Requires PHP 7.4 Release 3.0.0 Requires PHP 7.3 Release 2.0.0 Requires PHP 7.2 Release 1.0.0 Requires PHP 7.1 Installationcomposer create-project and enter in the created folder (you can fork or clone the repository if you want to)
(optional) Stop all other containers to avoid conflict.
Start project with Docker using compose tool.
Access the container
Run Composer to install all dependencies.
Ensure the composer install create the cache folders and give then permissions in ./storage, if don't you'll have to create and give permitions yourself:
To check the build for this project look at ./ops/docker/dev folder. Copy and modify the .env file
Include values for You can use Now you can access the health-check http://localhost:8101 and get a json response like this:
Requests samplesYou can find a sample of requests you can do in the file Not all requests are documented yet (Work in progress) Creating your automatic crud domainFor create your brand new domain with a complete crud use the command:
This command will create a folder in If your domain name has 2 words use underline (_) to separate. Configuring your new Domain
Running your Migration
UlidFor primary key value, this project using Ulid value, but you can pass other pattern in insert route if you prefer. JWTIn auth route this projet use JWT lib. This token will be generate if your secret, token and context is correct. This configuration is the We strongly advise you to change these values, they can be either random strings, ulids or any string that you like. We use to generate then by encrypting an ulid v4 with SHA512/256. We recommend creating diferents tokens from diferents sources.
Request ServiceTo make request between two or more services, this project use Request Service lib. ResponseThe pattern used to return all request is json and the layout is configure in your Response lib. Custom ValidatorsI you want to implement custom validators you can use the regex function and add you regex to the patterns file
FiltersFollow this steps to configure a new field to accepted a filter in list route
For example, to add a filter to
After that, you need to configure your filters in you can user various patterns like Check all types look at
After that you can send this param in url query, for example:
RecomendationsUse this project with MySql with no relationship keys and NOT use JOIN. ProductionDon't forget to change The production docker is located in DevelopmentWant to contribute? Great! Make a change and be careful with your updates! Any new code will only be accepted with all validations. To ensure that the entire project is fine: First install the dependences (with development ones)
Second run all validations
You can run all validations plus test coverage metrics
Code QualityWe create this project under stricts good pratices rules. Bellow you can see some composer commands to validate the framework code and your code as well. We recommend you aways run the lint - check for sintax errors on PHP (PHP Lint)
cs - check for smells in general (Code Snifer)
mess - check for smells in a more deep way (Mess Detector)
test - run all tests (Unit and Feature)
test-cover - run all tests with code coverage (Unit and Feature)
test-unit - run all unit tests
test-unit-cover - run all unit tests with code coverage
test-feat - run all feature tests
test-feat-cover - run all feature tests with code coverage
ccu - check unit coverage level (100% is required)
ccf - check feature coverage level (100% is required)
check - execute lint, cs, mess and unit tests
checkcover - execute lint, cs, mess and unit tests with coverage
checkall - execute lint, cs, mess, unit and feature tests
checkall - execute lint, cs, mess, unit and feature tests with coverage
SonarqubeThis project is also validated with Sonarqube, has a To do that, edit the Automatic Validation Before CommitIf you want to force the
Random Seed DataYou can create an automatic seeder to generate data using you add endpoint to tests purposes (or any other purpose you like). To do that you must create a random seeder with the command:
It will create a file inside You may change to fullfill your needs (and your domain validations) Now you may configure on And run your seed with the domain name and the amount to records to generate.
Then use the list endpoint, or make a select in database to see the results. Not Empty Foundation - Free codes, full minds |