This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

DotKernel API

This package is auto-updated.

Last update: 2021-12-08 10:27:46 UTC


README

DotKernel's PSR-15 API built around the Mezzio API skeleton based on Enrico Zimuel's Zend Expressive API skeleton example.

OSS Lifecycle

GitHub issues GitHub forks GitHub stars GitHub license

PHP from Packagist (specify version)

Getting Started

Step 1: Clone the project

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 .

Step 2: Install project dependencies

composer install

During the installation process you will be prompted:

Please select which config file you wish to inject 'Laminas\*\ConfigProvider' into:
  [0] Do not inject
  [1] config/config.php
Make your selection (default is 1):

Please enter 0 because the application has an injected ConfigProvider which already contains the prompted configurations.

Next, you will be prompted: Remember this option for other packages of the same type? (Y/n)

Please hit Enter to accept the default option, which will also leave other packages' ConfigProviders not injected.

Step 3: Development mode

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

Step 4: Prepare config files

  • duplicate config/autoload/cors.local.php.dist as config/autoload/cors.local.php <- if your API will be consumed by another application, make sure configure the allowed_origins
  • duplicate config/autoload/local.php.dist as config/autoload/local.php
  • duplicate config/autoload/mail.local.php.dist as config/autoload/mail.local.php <- if your API will send emails, make sure you fill in SMTP connection params

Optional:

  • duplicate phpcs.xml.dist as phpcs.xml
  • duplicate phpunit.xml.dist as phpunit.xml

Step 5: Setup database

  • 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]:

Hit Enter to confirm the operation.

Step 6: Test the installation

php -S 0.0.0.0:8080 -t public

Sending a GET request to the home page should output the following message:

{
  "message": "Welcome to DotKernel API!"
}

Using the CLI:

You can access the Mezzio's CLI by using the following command:

php vendor/bin/mezzio

You can access the Laminas' CLI by using the following command:

php vendor/bin/laminas

You can access Doctrine's CLI by using the following command:

php vendor/bin/doctrine

You can access DBAL CLI by using the following command:

php vendor/bin/doctrine-dbal

You can access Doctrine's migration tools by using the following command:

php vendor/bin/doctrine-migrations

You can access app-specific commands by using the following command:

php bin/cli.php