Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Siler Laravel Package

leocavalcante/siler

Siler is a zero-dependency PHP library/micro-framework of high-level functional abstractions for declarative apps and routing. Fast, flat-file friendly, and works well with Swoole. Note: the repository is archived; Nano is recommended as an alternative.

View on GitHub
Deep Wiki
Context7

Twig Templating

composer require twig/twig

{% hint style="info" %} Siler doesn't have direct dependencies, to stay fit, it favors peer dependencies, which means you have to explicitly declare a twig dependency in your project in order to use it. {% endhint %}

Siler will internally handle the Twig_Environment instance.

use Siler\Twig;

Twig\init('path/to/templates');

Actually it is also returned at init function call, so you call add Twig plugins, filters and functions, for example, adding Siler\Http\url into Twig's Environment to later reference static assets on the public folder:

Twig\init('path/to/templates')
    ->addFunction(new Twig_SimpleFunction('url', 'Siler\Http\url'));

At initialization, you can also provide a path to templates cache as second argument and if you want to let Twig debug as third argument (defaults to false):

$shouldTwigDebug = true;
Twig\init('path/to/templates', 'path/to/templates/cache', $shouldTwigDebug);

To render a template, simply call render at Twig namespace:

echo Twig\render('pages/home.twig');

An passing parameters can be done by the second argument:

$data = ['message' => 'Hello World'];
echo Twig\render('pages/home.twig', $data);

Something that can be confusing using Siler is that some function does outputs and other doesn't, like Twig\render. So remember that Twig\render will only return the rendered template within its given data and you should explicit output or let Response do it:

$html = Twig\render('pages/home.twig');
Response\html($html);

Also, remember that you can always bring you own template engine to the playground without any bridging stuff or use PHP itself on your views.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity