PHP code example of sinevia / laravel-cms

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

    

sinevia / laravel-cms example snippets


composer  

composer san migrate
php artisan vendor:publish --tag=config
// If you want the migrations, usually not needed
php artisan vendor:publish --tag=migrations
// If you want the views, usually not  needed
php artisan vendor:publish --tag=views

composer remove sinevia/laravel-cms

\Route::group(['prefix' => '/'], function () {
    // will match only one level deep (not recommended)
    \Route::any('/{path?}', '\Sinevia\Cms\Http\Controllers\CmsController@anyPageView');
    
    // or use with regex expression to match any level
    \Route::any('/{path?}', '\Sinevia\Cms\Http\Controllers\CmsController@anyPageView')
        ->where('path', '([a-zA-z0-9\/\-]++)');
        
    // or use with simpler regex expression to match any level
    \Route::any('/{path?}', '\Sinevia\Cms\Http\Controllers\CmsController@anyPageView')
        ->where('path', '.+');

    // or if you prefer using the class path (recommended)
    \Route::any('/{path?}', [\Sinevia\Cms\Http\Controllers\CmsController::class, 'anyPageView'])
        ->where('path', '.+');
});

\Route::group(['prefix' => '/admin'], function () {
    \Route::group(['middleware'=>'adminonly'], function(){
        \AdvancedRoute::controller('/cms', '\Sinevia\Cms\Http\Controllers\CmsController');

        // or if your prefer using class path (recommended)
        \AdvancedRoute::controller('/cms', \Sinevia\Cms\Http\Controllers\CmsController::class);
    });
});

preg_match('#^/article/([0-9]+)/([a-zA-Z]+)/([a-zA-Z]+)$#', '/' . $uri, $matched);
$articleId = $matched[1] ?? "";

// A small helper function to place HTML in the CMS template
function viewInTemplate($pageTitle, $pageContent) {
    $template = \Sinevia\Cms\Models\Template::find('20180126000128528925');

    return $template->render('en', [
                'page_title' => $pageTitle,
                'page_content' => $pageContent,
    ]);
}

// Then you may use from your controller, for instance to show a login form in
$html = view('guest/auth/login', get_defined_vars())->render();
return viewInTemplate('Login', $pageContent)