aurmil / slim2-skeleton
A Slim Framework 2 application skeleton
Installs: 218
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Type:project
Requires
- php: >=5.5.0
- flynsarmy/slim-monolog: ^1.0
- roave/security-advisories: dev-master
- slim/slim: ^2.6
- slim/views: ^0.1.3
- symfony/yaml: ~3.0
- twig/twig: ~1.0
README
What's included?
- Slim v2
- Twig v1
- Monolog v1
- Symfony Yaml Component v3
Installation
Required: Composer
Run the following command, replacing [your-project-name] with the name of the folder you want to create.
composer create-project aurmil/slim2-skeleton [your-project-name]
- Create a virtual host that points to your project path /public
- For Apache, make sure it has AllowOverride All for Slim URL rewriting
- Make sure var folder is writable by Web server
Web server choice
This skeleton includes a .htaccess file for Apache.
Feel free to read the Slim documentation if your prefer to use another Web server like nginx.
Configuration
Application configuration is stored in /app/config.yml which is divided into 2 main parts: general settings and environment-specific settings.
Environment settings are grouped within sections. A section = an environment. Section name = value of ENVIRONMENT env variable (default = development).
General settings are merged with environment-specific settings. The latter ones overwrite the first ones.
Access config in PHP code
In /app/src/bootstrap.php, the whole configuration is in the $config variable.
In a controller action, only the App section of configuration is available through $app->config('app').
$tmp = $app->config('app')['my_custom_setting_key'];
Access config in Twig template
Only the App section of configuration is in the config variable.
{{ config.my_custom_setting_key }}
Application errors by email
By configuring App.errors.send_email and App.errors.email, you can enable or disable sending email with Monolog when an error occurs.
Meta tags
Every key: value pair you add under App.metas will be output in HTML head section as a meta tag.
Title
Page title is a special case. Obviously, title and title_separator entries won't be output as meta tags like the other ones.
A page title is formed as follows:
- content of the metaTitle block a template child could define
{% block metaTitle %}my custom page title{% endblock %}
- if App.metas.title is not empty:
- if App.metas.title_separator is not empty: add the separator
- add the config title
License
The MIT License (MIT). Please see License File for more information.