Js php

Is this PHP or Javascript?

I've been playing around in the Pagekit CMS the last few weeks and I have learned so much in this period. I have always worked with the Joomla! CMS code and got used the the style of coding, the way code is loaded and executed. Now all that has changed. Pagekit is based on a completely different way of doing things, and I like it!

The PHP code is getting more and more event based. And the syntax is getting more and more javascript like. Starting of course with the [] notation for arrays. But the first time I saw functions being passed around in arrays, with the use statement adding some variables, my mind blew. They are actually called Closures and have been around for a while. But I have never seen that used like that before.

<?php

use Pagekit\Auth\Auth;

return [

    'name' => 'system/login',

    'label' => 'Login',

    'events' => [

        'view.scripts' => function ($event, $scripts) use ($app) {
            $scripts->register('widget-login', 'system/user:app/bundle/widget-login.js', ['~widgets', 'input-link']);
        }

    ],

    'render' => function ($widget) use ($app) {

        $user              = $app['user'];
        $redirect          = $widget->get($user->isAuthenticated() ? 'redirect_logout' : 'redirect_login') ?: $app['url']->current(true);
        $last_username     = $app['session']->get(Auth::LAST_USERNAME);

        return $app['view']('system/user/widget-login.php', compact('widget', 'options', 'user', 'last_username', 'redirect'));
    }

];

This is the complete code of the login widget from the Pagekit core. I think it is pure beauty!

{{ message }}

{{ 'Comments are closed.' | trans }}