PHP code example of particle-academy / fancy-seo
1. Go to this page and download the library: Download particle-academy/fancy-seo 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/ */
particle-academy / fancy-seo example snippets
use FancySeo\Facades\FancySeo;
use FancySeo\JsonLd;
FancySeo::defaults([
'site_name' => 'Fancy UI',
'image' => '/og/default.png',
'twitterSite' => '@particleacademy',
'jsonLd' => [
JsonLd::website('Fancy UI', url('/'), searchUrlTemplate: url('/search?q={search_term_string}')),
JsonLd::softwareApplication('Fancy UI', url('/'), ['applicationCategory' => 'DeveloperApplication', 'operatingSystem' => 'Web', 'price' => '0']),
],
]);
FancySeo::route('packages.show', fn (array $params) => [
'title' => "{$params['package']} — Fancy UI",
'jsonLd' => [JsonLd::softwareSourceCode($params['package'], url("/packages/{$params['package']}"), "https://github.com/Particle-Academy/{$params['package']}", ['programmingLanguage' => 'TypeScript'])],
]);
FancySeo::noindexRoutes(['admin.*', 'auth.*']);
FancySeo::for(['title' => $post->title, 'description' => $post->excerpt, 'type' => 'article']);
FancySeo::sitemap(function ($map) {
$map->add('/', '1.0', 'daily');
foreach (Package::all() as $pkg) {
$map->add("packages/{$pkg->slug}", '0.8');
}
});
FancySeo::llms(fn (FancySeo $seo) => view('seo.llms')->render());
FancySeo::markdownUsing(fn (string $path) => MarkdownContent::for($path)); // null → 404
FancySeo::for([
'image' => '/og/react-fancy.png',
'imageAlt' => 'react-fancy — Tailwind v4 React primitives',
'imageWidth' => 1200,
'imageHeight' => 630,
'imageType' => 'image/png',
]);
bash
php artisan vendor:publish --tag=fancy-seo-config