PHP code example of junker / smarty-service-provider
1. Go to this page and download the library: Download junker/smarty-service-provider 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/ */
$app->get('/hello/{name}', function ($name) use ($app) {
return $app['smarty']->display('hello.tpl', [
'name' => $name,
]);
});
$smarty2 = $app['smarty.new_instance']();
class Application extends \Silex\Application
{
use \Junker\Silex\Application\SmartyTrait;
}
$app->render('hello.tpl', [
'name' => $name,
]);
smarty
{path _name='app.login'}
same as $app['url_generator']->generate('app.login');
{path _name='app.product' id=11}
same as $app['url_generator']->generate('app.product', ['id' => 11]);
{url _name='app.login'}
same as $app['url_generator']->generate('app.login', UrlGeneratorInterface::ABSOLUTE_URL);
{trans _name='err.access_forbidden'}
same as $app['translator']->trans('err.access_forbidden');
{trans _name='warn.my_city' city='London'}
same as $app['translator']->trans('warn.my_city', ['%city%' => 'London']);
{trans}hello{/trans}
same as $app['translator']->trans('hello');
{transChoice _name='days' _count=5}
same as $app['translator']->transChoice('days', 5, ['%count%' => 5]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.