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 :
- twig-view for the views.
- doctrine for the database.
- data-fixtures for the data fixture.
- validation to validate the data.
- csrf for form security.
- php-ref for an improved var_dump function.
- phpdotenv for the configuration of the environment.
- console for terminal commands.
- monolog to manage logs.
- runtracy for a profiler.
- slim-secure-session-middleware helpers for session management.
- translation for the multilingual system.
- webpack for compilation and minification of files scss/sass/css/js.
- slim-router-js url generator slim in javascript code.
- cli-menu for execute commands from a menu in your terminal.
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
- Php >= 7.1.3
Slim Sim relies on dependencies that require a recent php version.
- MySQL/PostgreSQL/SQLite
Using Doctrine ORM, you must have a database available.
- Node.js >= 6.11.5
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 dependencieserror_pages.php
the views in case of errorfunctions.php
functions accessible anywhere in the codemiddlewares.yml
middlewares call fileroutes.yml
route filetracy.php
tracy configuration file (debugbar)
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