PHP code example of antlur / laravel-static-export
1. Go to this page and download the library: Download antlur/laravel-static-export 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/ */
// web.php
Route::get('/blog/{slug}', [BlogController::class, 'show']);
// app/Http/Controllers/BlogController.php
use Antlur\Export\Attributes\ExportPaths;
class BlogController
{
// You can pass a class that implements PathProvider
#[ExportPaths(BlogPostPaths::class)]
public function show(string $name)
{}
// Or you can pass an array of paths directly
#[ExportPaths(['/blog/first-post', '/blog/second-post'])]
public function show(string $name)
{}
}
// app/PathProviders/BlogPostPaths.php
class BlogPostPaths implements \Antlur\Export\Contracts\PathProvider
{
public function paths(): array
{
return [
'/blog/first-post',
'/blog/second-post',
];
}
}