Download the PHP package tavib47/slim-boilerplate without Composer
On this page you can find all versions of the php package tavib47/slim-boilerplate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tavib47/slim-boilerplate
More information about tavib47/slim-boilerplate
Files in tavib47/slim-boilerplate
Package slim-boilerplate
Short Description Slim Framework 4 boilerplate with Twig templating
License MIT
Informations about the package slim-boilerplate
Slim Framework Boilerplate
A modern PHP boilerplate built with Slim Framework 4 and Twig templating, pre-configured with DDEV for local development and code quality tools.
Prerequisites
Quick Start
-
Create a project:
-
Copy environment configuration:
-
Start DDEV and install dependencies:
- Open in browser:
Project Setup
Before starting development, configure these files:
| File | Purpose |
|---|---|
.env |
Environment variables (database, mail, app settings) |
.ddev/config.yaml |
DDEV project configuration |
composer.json |
Update project name and description |
Features
| Feature | Description |
|---|---|
| Slim Framework 4 | Fast, minimal PHP micro-framework |
| Twig 3 | Secure template engine with inheritance and components |
| PHP-DI | Autowiring dependency injection container |
| Sass/SCSS | Modular stylesheets with variables and partials |
| Multilingual (i18n) | URL-based locale detection, translated routes, YAML translations |
| Session Management | PHP sessions with flash messages |
| Contact Form | Ready-to-use form with SMTP email (PHPMailer) |
| GDPR Cookie Banner | Cookie consent with localStorage |
| Environment Config | .env file support via phpdotenv |
| Code Quality | PHPCS, PHPStan, pre-commit hooks |
Configuration
All configuration is managed via environment variables in .env:
Application
Database
Mail (SMTP)
Project Structure
Development Workflow
Starting and Stopping
Running Commands
Database Access
Adding New Pages
For static pages (using PageController), you only need two steps:
-
Add a route to the
$routesarray inconfig/routes.php: - Create a template in
templates/pages/terms.twig:
Routes are automatically registered for all supported locales. To add translated URL slugs, see the Multilingual Support section.
For pages with custom logic, create a controller:
-
Create a controller in
src/Controllers/: -
Add a route in
config/routes.php: - Create a template in
templates/pages/my-page.twig
Theme Development (Sass/CSS)
Stylesheets are written in Sass and compiled to CSS. Source files are in scss/, compiled output goes to public/css/style.css.
Commands
File Structure
Adding New Styles
- New component: Create
scss/components/_my-component.scss, add@use 'my-component';to_index.scss - New page styles: Add to
scss/_pages.scssor create a new partial - New variables: Add to
scss/_variables.scss
Each partial uses @use '../variables' as *; to access variables.
Multilingual Support (i18n)
The boilerplate includes a complete internationalization system with URL-based locale detection and translated routes. All routes defined in config/routes.php are automatically registered for each supported locale.
URL Structure
- Default locale has no prefix:
/about,/contact - Other locales are prefixed with translated slugs:
/ro/despre-noi,/fr/a-propos
Configuration
Configure languages in config/settings.php under the locale key:
Adding Route Translations
When you add a new route, you can optionally add translated URL slugs:
-
Add the route to
config/routes.php: - Add translated slugs in
config/settings.php:
This will generate:
/terms(English - default, no prefix)/ro/termeni(Romanian)/fr/conditions(French)
Translation Files
Translations are stored in YAML files in the translations/ directory:
Using Translations in Templates
Locale-Specific Template Overrides
You can override templates for specific locales by placing them in a locale subdirectory:
The system checks for pages/{locale}/template.twig first, then falls back to pages/template.twig.
Code Quality Tools
This boilerplate includes pre-configured code quality tools that run automatically on commit.
Available Commands
Standards
- PSR-12 - PHP coding standard
- Slevomat Coding Standard - Additional strict rules (type hints, unused code detection, etc.)
- PHPStan Level 6 - Static analysis
Git Hooks
Pre-commit hooks are automatically configured via composer install. They run all code quality checks before each commit.
MailHog (Email Testing)
DDEV includes MailHog for capturing outgoing emails during development.
Or visit: https://your-project.ddev.site:8026
License
MIT
All versions of slim-boilerplate with dependencies
slim/slim Version ^4.14
slim/psr7 Version ^1.7
slim/twig-view Version ^3.4
php-di/php-di Version ^7.0
vlucas/phpdotenv Version ^5.6
phpmailer/phpmailer Version ^6.9
symfony/translation Version ^7.0
symfony/yaml Version ^7.0