PHP code example of sashagm / cpu

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

    

sashagm / cpu example snippets


return [
    'cpu_url' => 1,  // 1 - Режим slug, 0 - Режим id
    'routes' => [
        [
            'name' => 'post',   // Маршрут
            'model' => 'App\Models\Post', // Модель
            'query' => ['slug'] // Параметр для slug
        ],
        [
            'name' => 'user',
            'model' => 'App\Models\User',
            'query' => ['id']
        ]
    ]
];


Route::get('/post/{post}', function (App\Models\Post $post) {

    dump($post);
    
})->name('post');