- Notifications
You must be signed in to change notification settings - Fork4
DotKernel's PSR-7 REST style API built around the Mezzio API skeleton.
License
dotkernel/api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
DotKernel API is a PHP skeleton app for building REST APIs usingLaminas andMezzio components and implements standards like PSR-3, PSR-4, PSR-7, PSR-11 and PSR-15.
Dotkernel API is an alternative for legacy Laminas API Tools (formerly Apigility) applications, and is based on Enrico Zimuel'sZend Expressive API - Skeleton example.
Livedemo.
Documentation is available at:https://docs.dotkernel.org/api-documentation/
Using your terminal, navigate inside the directory you want to download the project files into. Make sure that the directory is empty before proceeding to the download process. Once there, run the following command:
git clone https://github.com/dotkernel/api.git .
composer install
If you're installing the project for development, make sure you have development mode enabled, by running:
composer development-enable
You can disable development mode by running:
composer development-disable
You can check if you have development mode enabled by running:
composer development-status
- duplicate
config/autoload/cors.local.php.dist
asconfig/autoload/cors.local.php
<- if your API will be consumed by another application, make sure configure theallowed_origins
- duplicate
config/autoload/local.php.dist
asconfig/autoload/local.php
- duplicate
config/autoload/mail.local.php.dist
asconfig/autoload/mail.local.php
<- if your API will send emails, make sure you fill in SMTP connection params - optional: in order to run/create tests, duplicate
config/autoload/local.test.php.dist
asconfig/autoload/local.test.php
<- this creates a new in-memory database that your tests will run on
create a new MySQL database - set collation to
utf8mb4_general_ci
fill out the database connection params in
config/autoload/local.php
under$databases['default']
run the database migrations by using the following command:
php vendor/bin/doctrine-migrations migrate
This command will prompt you to confirm that you want to run it:
WARNING! You are about to execute a migration in database "..." that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
HitEnter
to confirm the operation.
Fixtures are used to seed the database with initial values and should be executed after migrating the database.
To list all the fixtures, run:
php bin/doctrine fixtures:list
This will output all the fixtures in the order of execution.
To execute all fixtures, run:
php bin/doctrine fixtures:execute
To execute a specific fixture, run:
php bin/doctrine fixtures:execute --class=FixtureClassName
More details on how fixtures work can be found here:https://github.com/dotkernel/dot-data-fixtures#creating-fixtures
php -S 0.0.0.0:8080 -t public
Sending a GET request to thehome page should output the following message:
{"message": "DotKernel API version 5"}
In order to access DotKernel API documentation, check the providedreadme file.
Additionally, each CLI command available has it's own documentation:
About
DotKernel's PSR-7 REST style API built around the Mezzio API skeleton.