PHP code example of noadek / twiggy

1. Go to this page and download the library: Download noadek/twiggy 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/ */

    

noadek / twiggy example snippets


'providers' => [
     ...
                Twiggy\Provider\TwiggyServiceProvider::class,
],

php artisan vendor:publish --provider="Twiggy\Provider\TwiggyServiceProvider"

//app/Http/routes.php
//twig template themes/hello.twig
Route::get('/', function () {
    return twig('hello');
});


...

    setTheme('default');




namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PagesController extends Controller
{
    public function __construct()
    {
        setTheme('default');
        setLayout('index');
    }

    public function index()
    {
        $name = 'I am Twiggy';

		return twig('index', compact('name'));
    }

    public function test()
    {
        setLayout('blog');

        return twig('post');
    }
}



namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PagesController extends Controller
{
    public function __construct()
    {
        setTheme('default');
        setLayout('index');
        setPageTitle('Pages');
    }

    public function index()
    {
        appendPageTitle('About Me');

        $name = 'I am Twiggy';

		return twig('index', compact('name'));
    }
    ...
}

    setPageTitle('Pages', 'About Me');



namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PagesController extends Controller
{
    public function __construct()
    {
        setTheme('default');
        setLayout('index');
        setPageTitle('Pages');
    }

    public function index()
    {
        appendPageTitle('About Me');
        setMetatag('description', 'This is all you need to know about twiggy');
        setMetatag('og:url', url('images/me.jpg'), 'property');

        $name = 'I am Twiggy';

		return twig('index', compact('name'));
    }
    ...
}

"register_functions" => [
    'date',
    'phpversion',
    'foo'
],

class AppServiceProvider extends ServiceProvider
{
	protected $defer = true;

	public function boot()
	{
		$this->registerHelper();
	}

	private function registerHelper()
	{
		

+-{APPPATH}/
| +-Lib/
| | +-helpers.php