PHP code example of bmatovu / laravel-js-routes

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

    

bmatovu / laravel-js-routes example snippets


$int = '^\d+$';

Route::pattern('post', $int);
Route::pattern('comment', $int);

Route::group(['prefix' => 'posts', 'as' => 'posts.'], function () {
    Route::get('/', 'PostController@index')->name('index');
    Route::get('/{post}/comments/{comment?}', 'PostController@comments')->name('comments');
    Route::delete('/{post}', 'PostController@destroy')->name('destroy');
});
bash
php artisan js-routes:generate
bash
php artisan vendor:publish --provider="Bmatovu\JsRoutes\JsRoutesServiceProvider"