Skip to content

Instantly share code, notes, and snippets.

@dorantor
Last active May 31, 2017 18:26
Show Gist options
  • Save dorantor/4c4b831378c8ac4f614a44d684289979 to your computer and use it in GitHub Desktop.
Save dorantor/4c4b831378c8ac4f614a44d684289979 to your computer and use it in GitHub Desktop.
PHPixie3 recipes

Migrations support folders, so it is possible to create symlinks like this: /assets/migrate/migrations/somebundle -> /vendor/some/bundle/assets/migrations/

<?= $this->render('fairy/greeting', ['name' => 'Trixie']) ?>
// 1. group /admin/ routes
'admin' => [
    'path' => 'admin/'
    'type' => 'prefix',
    'defaults' => ['requireLogin' => true],
    'resolver' => [
        'type' => 'group',
        'resolvers' => [
            // here comes admin routes but w/o /admin/ prefix
        ],
    ],
]

result: all request to /admin/... pages will have parameter 'requireLogin' after that, in bundle HTTP.php

public function process($request)
{
    if ($request->attributes()->get('requireLogin')) {
        if (user is not logged in.....) {
            return redirect;
        }
    } 

    return parent::process($request);
}

this way later you can add the same requireLogin param to any route and it will go through check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment