PHP code example of shadowprince / slimext

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

    

shadowprince / slimext example snippets


$app->prefix("/uac", function () use ($app) {
    // Route registered as /uac/login
    $app->get("/login", function () use ($app) {
        $app->render("login", array());
    });
});

$app->prefix("/uac", Middleware::userLogged(), function () use ($app) {
    $app->prefix("/edit", function () use ($app) {
        $app->map("/avatar", function () use ($app) {});
        $app->map("/info", function () use ($app) {});
        $app->prefix("/photos", Middleware::userCanManagePhotos(), function () use ($app) {
            $app->map("/upload", function () use ($app) {});
            $app->map("/delete/:id", function ($id) use ($app) {});
            $app->map("/edit/:id", function ($id) use ($app) {});
        });
    });
});

$app->prefix("/admin", Midleware::userAdmin(), function () use ($app) {
    // Routes registered with Middleware::userAdmin() middleware
    $app->get("/", function () use ($app) {/* ... */});
    $app->get("/users", function () use ($app) {/* ... */});
});

// Uac/urls.php
$app->prefix("/uac", function () use ($app) {
    $app->map("/login", function () use ($app) {
        // ...
    });
});
// bootstrap
$app->config("comps", array("Uac"));
$app->loadComponents();

class MyApp extends \SlimExt\SlimExt {
    public function user() {
        return $this->user_service_instance;
    }
}

class UserService extends \SlimExt\SlimService {
    public function __construct($app) {
        $this->defaultConfig($app, array(
            "default config" => "can be here"
        ));
    }

    public function isLogged() {
        // ...
    }
}