carc1n0gen / slim-starter
A starter app for building php applications with the Slim micro framework
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- bryanjhv/slim-session: ~3.0
- monolog/monolog: ^1.23
- php-di/slim-bridge: ^1.1
- slim/csrf: ^0.8.2
- slim/slim: ^3.0
- slim/twig-view: ^2.3
- twig/twig: ^1.0
This package is not auto-updated.
Last update: 2022-08-06 17:51:23 UTC
README
A starter app for building php applications with the Slim micro framework
What's Included?
- Autowiring with PHP-DI
- Twig templates
- Monolog logging
- Csrf Protection (With a twig extension)
- Sessions (with a twig extension)
Usage
Session
Inject the \SlimSession\Helper in to your code and then you can set and get session variables easily.
use SlimSession\Helper as SessionHelper; $app->get('/something', function ($request, $response, SessionHelper $session) { // Three ways to get and set session variables // 1 $session->someVar = 'Sweet'; $message = $session->someVar; // 2 $session->set('someVar', 'Sweet'); $message = $session->get('someVar'); // 3 $session['someVar'] = 'Sweet'; $message = $session['someVar']; ... });
There's also a twig extension preloaded which allowes you to easily get session values in your twig views
<p>{{ session('someVar') }}</p>
Csrf
When creating a form you will need to add a hidden token field. This is taken care of with a simple include:
<form ...> {% include '_csrf.twig' %} ...
License
slim-starter is open-sourced software licensed under the MIT license.