slimphp / slim-documentation Goto Github PK
View Code? Open in Web Editor NEWOld Slim Framework 3 documentation
Old Slim Framework 3 documentation
Any update when you will have documentation sorted in full?
According to http://docs-new.slimframework.com/features/templates/ ("Register the view service"), the code to use is:
// Create Slim app
$app = new \Slim\App();
// Register Twig View service
$app->register(new \Slim\Views\Twig('path/to/templates', [
'cache' => 'path/to/cache'
]));
However that throws a fatal error Call to undefined method Slim\App::register()
.
From the readme at https://github.com/slimphp/Twig-View it seems the correct code is actually:
// Create Slim app
$app = new \Slim\App();
// Fetch DI Container
$container = $app->getContainer();
// Register Twig View helper
$container->register(new \Slim\Views\Twig('path/to/templates', [
'cache' => 'path/to/cache'
]));
.. which seems to at least get rid of the error.
I tried to find where the installation document was to make a PR but have failed.
My suggestion is to recommend that rather than manually creating composer.json then copying and pasting from the file, simply use composer require slim/slim
to install and Composer will create the file for you.
Hey,
We should add a chapter on testing, so people can learn and improve their code.
Thanks
Does the section on caching just need to get updated to show how to use slim/http-cache?
Hi,
I think it is good to show how to inject a Twig view rather than calling $this['view']
inside controller / anonymous function.
$app->get('/hello/{name}', function ($request, $response, $args) {
$this['view']->render('profile.html', [
'name' => $args['name']
]);
})->setName('profile');
The idea is even if we are using a different framework, we can make use of the code without changes.
New users often seem confused regarding how slim populates params()/get()/post(). Content-Type application/json isn't supported by default, and users have been posting to a route with json data and not receiving anything from request->post().
We should improve the documentation with examples on how to correctly POST application/json data to a slim route, and now to receive that data.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.