PHP code example of tsirosgeorge / semantic

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

    

tsirosgeorge / semantic example snippets


   View::render('login', $data, 'auth');
   

router->group([], function ($router) {
    $router->addRoute('GET', '/', 'AuthController@showLoginForm');

    $router->group(['middleware' => 'auth'], function ($router) {
        $router->addRoute('GET', '/dashboard', 'DashboardController@index');
        $router->addRoute('GET', '/dashboard/members', 'DashboardController@members');
        $router->addRoute('GET', '/dashboard/b2binterest', 'DashboardController@b2binterest');
    });
});

// Group for API Routes
$router->group(['prefix' => '/api'], function ($router) {
    // Auth Routes
    $router->addRoute('GET', '/logout', 'AuthController@logout');
    $router->addRoute('POST', '/login', 'AuthController@login');
    $router->addRoute('POST', '/register', 'AuthController@register');
    $router->addRoute('GET', '/refresh-session', 'AuthController@refreshSession');

    $router->group(['middleware' => 'auth'], function ($router) {
        $router->addRoute('GET', '/dashboard/data', 'DashboardController@loadData');
        $router->addRoute('POST', '/b2binterest', 'api\B2BInterestController@create');
        $router->addRoute('PUT', '/b2binterest/{id}', 'api\B2BInterestController@update');
    });
});

In this example:

- Routes without the `api/` prefix are used for regular page requests.
- Routes with the `api/` prefix are designated for API requests.
- To protect a route, add `'auth'` as the third parameter. This indicates that the route