PHP code example of studiow / plates-http-factory

1. Go to this page and download the library: Download studiow/plates-http-factory library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

studiow / plates-http-factory example snippets


   
   $factory = new \Studiow\Plates\ResponseFactory(
       new \League\Plates\Engine('/path/to/templates'), //the plates engine
       new \Http\Factory\Guzzle\ResponseFactory()      //a psr-17 compatible response factory
   );
   
   //rendering the template at /path/to/templates/pages/home.php with additional data
   $response = $factory->createResponse(
       'pages/home',
       ['title'=>'home']
   );
   

   $factory = new \Studiow\Plates\ResponseFactory(
       new \League\Plates\Engine('/path/to/templates'),
       new \Http\Factory\Guzzle\ResponseFactory()
   );
   
   $response = $factory->createResponse(
       'error/page-not-found', //name of the template
       ['title'=>'Page not found!'], //data to be passed to the template
       404,     //http status code
       'Not Found' //http reason phrase
   );