slim4/gslim-skeleton

slim 4 microservice skeleton

v1.1.0 2021-04-14 08:20 UTC

This package is auto-updated.

Last update: 2024-04-15 20:31:53 UTC


README

Useful framework for RESTful API development with JSON schema validation, using Slim PHP micro framework.

Used technologies: "PHP 7, Slim 4, MySQL, Doctrine, PHPUnit, dotenv & vagrant".

Software License

⚙️ QUICK INSTALL:

Requirements:

  • Composer.
  • PHP 7.2+.
  • MySQL/MariaDB.
  • or Vagrant.

With Composer:

You can create a new project running the following commands:

$ composer create-project slim4/gslim-skeleton [my-app]

Configure your connection to MySQL Server:

By default, the API use a MySQL Database.

You should check and edit this configuration in your scr/Config/.env file:

APP_URL=http://yourproject.lo/
APP_DEBUG=true
APP_ID=1
APP_ENV=local

#Database
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=gslim
DB_USERNAME=vagrant
DB_PASSWORD=vagrant
DB_CHARSET=utf8
DB_COLLATION=utf8_unicode_ci
DB_PREFIX=


# Cache twig
CACHE=false

#LOG_PATH
LOG_PATH='storage/logs/app.log'

📦 DEPENDENCIES:

LIST OF REQUIRE DEPENDENCIES:

  • slim/slim: Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
  • slim/psr7: PSR-7 implementation for use with Slim 4.
  • slim/csrf: Slim Framework CSRF Protection.
  • doctrine/orm: Object Relational Mapper.
  • justinrainbow/json-schema: JSON Schema for PHP.
  • vlucas/phpdotenv: Loads environment variables from .env to getenv(), $_ENV and $_SERVER automagically.

LIST OF DEVELOPMENT DEPENDENCIES:

  • phpunit/phpunit: The PHP Unit Testing framework.
  • symfony/console: The Console component eases the creation of beautiful and testable command line interfaces

PHP Slim command line: $ php slim

  Slim Command Management Console 1.0

  Usage:
    command [options] [arguments]

  Options:
    -h, --help            Display help for the given command. When no command is given display help for the list command
    -q, --quiet           Do not output any message
    -V, --version         Display this application version
        --ansi            Force ANSI output
        --no-ansi         Disable ANSI output
    -n, --no-interaction  Do not ask any interactive question
    -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

  Available commands:
    help              Display help for a command
    list              List commands
    migrate           Perform database migration

  make
    make:command      Create command file
    make:controller   Create interface controller
    make:entity       Create Entity e. g. UserAccess = tablename user_access
    make:exception    Create service interface
    make:middleware   Create Middleware
    make:migration    Create database migration file e. g. create_user_access_table / update_user_access_table
    make:service      Create service interface
    make:trait        Create interface trait
  migrate
    migrate:rollback  Roll back the database migration
  schedule
    schedule:run      Run timed task scheduling commands

🔖 ENDPOINTS:

BY DEFAULT:

  • CSRF Token: GET /api/token

  • Health Check: GET /healthcheck

😎 THAT'S IT!

Now go build a cool SLIM API.