Inside the bootstrap/app.ph add the following code
Where autoload.php will load all the dependencies of our slim applicaiton.
Inside the index.php add the following code to access
Now we can access our public folder as http://localhost/testApp/public/
Step 2: Create routes
Slim doesn’t use any automatic mapping or URL formula so you can make any route pattern you like map onto any function you like, it’s very flexible. Routes can be linked to a particular HTTP verb (such as GET or POST), or more than one verb.
Create new folder app in root folder and add new file routes.php inside
We have to add httaccess file, .htaccess is short for Hypertext Access is a configuration file for use on web servers running the Apache Web Server software. With .httaccess now we can access
Step 2: Installing Twig template
The Slim Framework view helper built on top of the Twig templating component. You can use this component to create and render templates in your Slim Framework application.
composer require slim/twig-view
Our resources folder add new folder called views, where we can store all about views. Inside resources/views/home.twig add code
In bootstrap/app.php add the following code to add view dependency to container to the
In above code we have first attach our view template to container and we are also creating new slim instance we have to define path where our view are kept. For the production we may keep our cache in different folder.
We can also add optional addExtension to define routes, we need router because we are using link inside our view and we also have to get current uri through request which is the current request of the page.
In app/routes.php we have to add following code to access view page home.twig