niklongstone / puli-example

Example files related to the SitePoint Puli PHP article

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resource management with Puli example files

This repository contains the example files related to the SitePoint article on Puli.

Step 1 - Managing resources in PHP

####master branch

  • Make sure you have Composer and you have installed the Puli CLI.
  • Run composer install to install all the required dependency.
  • Run puli map /myapp res to map all the resources.
  • Open index.php to see the result.

Step 2 - URL generation

####git checkout step-2

  • Run composer require puli/url-generator:^1.0 to require the Url Generator Puli package.
  • Run puli server --add myserver public_html to make the server link to the public_html folder.
  • Run puli publish /myapp/public myserver to register the path.
  • Run `puli publish --install' to create symlinks of the /res/public elements into the public_html path
  • Open url-generation.php to see the absolute path output.

Step 3 - Usage with Twig

####git checkout step-3

  • Run composer update to install the required dependencies.
  • Modify the lines 9 and 60 of the views/index.html.twig as follow:
9:     <link rel="stylesheet" href="{{ resource_url('../public/css/style.css') }}">
...
60:    <img src="{{ resource_url('../public/images/200x200.gif') }}" alt="Post thumbnail" class="thumbnail" />

Note: The resource_url specified will refer to the public resource in the web root directory as in Step 2

  • Open twig-example.php to see the final result.

About

Example files related to the SitePoint Puli PHP article


Languages

Language:CSS 84.4%Language:HTML 14.9%Language:PHP 0.7%