Introduction

Slim Sim is a skeleton based on PHP micro framework Slim, adopting a simple and effective MVC architecture, it will allow you to develop your sites and web applications in a clean and organized structure. The underlying architecture is built using well-established and up-to-date technologies.

Some of these key technologies :

NOTE

cli-menu use php posix extension which is not supported on windows, remember to delete this line in composer.json if you are under windows :

"php-school/cli-menu": "^3.0"

Prerequisites

Slim Sim relies on dependencies that require a recent php version.

  • MySQL/PostgreSQL/SQLite

Using Doctrine ORM, you must have a database available.

The framework has webpack 4 for the front-end part and needs a newer nodejs version as possible.

  • OS supporté: Linux, MacOS et Windows

Linux and MacOS are however recommended.

Installation

Composer

$ composer create-project simondevelop/slim-sim <projet_name>
$ cd <projet_name>
$ composer install
$ npm install

Git

$ git pull https://github.com/SimonDevelop/slim-sim.git <projet_name>
$ cd <projet_name>
$ composer install
$ npm install

Check that the .env file has been created, this is the configuration file of your environment or you define the connection to the database, the environmentdev or prod and the activation of the twig cache.

If the file has not been created, do it manually by duplicating the .env.example file.

Be sure to check that your database environment configuration matches well and allow the storage folder to write, example chmod 774.

Configuration

Apache2

<VirtualHost *:8080>
    ServerName 127.0.0.1:8080
    DocumentRoot "/path/to/project/slim-sim/public/"
    <Directory "/path/to/project/slim-sim/public/">
        Options -Indexes +FollowSymLinks
        AllowOverride all
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

Nginx

server {
    listen 8080;
    server_name localhost;
    index index.php;
    root /path/to/project/slim-sim/public;

    error_log /path/to/example.error.log;
    access_log /path/to/example.access.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ ^/.+\.php(/|$) {
        try_files $uri /index.php = 404;
	    fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Docker

You have at your disposal a docker-compose.yml file at the root of the project, adapt the configuration files including the docker files in thedocker folder and then run the command:

$ docker-compose up -d

Tree

  • app/src/ folder of the application
    • Controllers/ folder of controllers
    • Entity/ folder of doctrine entity
    • Middlewares/ folder of middlewares
    • Views/ folder of twig views
  • assets/ folder of front-end files (css/js...)
  • config/ application configuration files folder
    • commands terminal command configuration folder
    • translations folder of translation files used in twig views
    • cli-config.php cli file for doctrine commands
    • container.php the container of dependencies
    • error_pages.php the views in case of error
    • functions.php functions accessible anywhere in the code
    • middlewares.yml middlewares call file
    • routes.yml route file
    • tracy.php tracy configuration file (debugbar)
  • public/ public folder of the application
  • storage
    • cache/ twig cache of the application
    • logs/ the logs of monolog
  • tests/ unit tests file
  • .env database environment file
  • console php file of cli commands
  • webpack.config.js webpack configuration file