# Introduction
Slim Sim is a skeleton based on PHP micro framework Slim (opens new window), 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 :
- twig-view (opens new window) for the views.
- doctrine (opens new window) for the database.
- data-fixtures (opens new window) for the data fixture.
- migrations (opens new window) for the migrations of the database.
- validation (opens new window) to validate the data.
- csrf (opens new window) for form security.
- php-ref (opens new window) for an improved var_dump function.
- phpdotenv (opens new window) for the configuration of the environment.
- console (opens new window) for terminal commands.
- monolog (opens new window) to manage logs.
- translation (opens new window) for the multilingual system.
- webpack (opens new window) for compilation and minification of files scss/sass/css/js.
- cli-menu (opens new window) for execute commands from a menu in your terminal.
# NOTE
cli-menu (opens new window) 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": "^4.0"
# Prerequisites
- Php (opens new window) >= 7.2
Slim Sim relies on dependencies that require a recent php version.
- MySQL/PostgreSQL/SQLite
Using Doctrine (opens new window) 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 applicationControllers/
folder of controllersEntity/
folder of doctrine entityMiddlewares/
folder of middlewaresViews/
folder of twig views
assets/
folder of front-end files (css/js...)config/
application configuration files foldercommands
terminal command configuration foldertranslations
folder of translation files used in twig viewscli-config.php
cli file for doctrine commandscontainer.php
the container of dependenciesfunctions.php
functions accessible anywhere in the codemiddlewares.php
middlewares call fileroutes.php
route file
public/
public folder of the applicationstorage
cache/
twig cache of the applicationlogs/
the logs of monolog
tests/
unit tests file.env
database environment fileconsole
php file of cli commandswebpack.config.js
webpack configuration file