1. Go to this page and download the library: Download melbahja/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/ */
melbahja / seo example snippets
use Melbahja\Seo\Schema;
use Melbahja\Seo\Schema\Thing;
use Melbahja\Seo\Schema\Organization;
$schema = new Schema(
new Organization([
'url' => 'https://example.com',
'logo' => 'https://example.com/logo.png',
'contactPoint' => new Thing(type: 'ContactPoint', props: [
'telephone' => '+1-000-555-1212',
'contactType' => 'customer service'
])
])
);
echo $schema;
use Melbahja\Seo\Schema;
use Melbahja\Seo\Schema\Thing;
use Melbahja\Seo\Schema\CreativeWork\WebPage;
$product = new Thing(type: 'Product');
$product->name = "Foo Bar";
$product->sku = "sk12";
$product->image = "/image.jpeg";
$product->description = "testing";
$product->offers = new Thing(type: 'Offer', props: [
'availability' => 'https://schema.org/InStock',
'priceCurrency' => 'USD',
"price" => "119.99",
'url' => 'https://gool.com',
]);
$webpage = new WebPage([
'@id' => "https://example.com/product/#webpage",
'url' => "https://example.com/product",
'name' => 'Foo Bar',
]);
$schema = new Schema(
$product,
$webpage,
);
echo json_encode($schema, JSON_PRETTY_PRINT);
$sitemap = new Sitemap('https://example.com',
[
'saveDir' => './storage',
'mode' => OutputMode::TEMP
]);
$sitemap->render(); // Saves to temp dir and save to disk only on generation success.
$sitemap = new Sitemap('https://example.com',
[
'saveDir' => './storage',
'mode' => OutputMode::FILE
]);
$sitemap->render(); // Saves to disk
$sitemap = new Sitemap('https://example.com', [
'mode' => OutputMode::MEMORY
]);
$xml = $sitemap->render(); // Returns XML string
use Melbahja\Seo\Indexing\GoogleIndexer;
use Melbahja\Seo\Indexing\URLIndexingType;
$indexer = new GoogleIndexer('your-google-access-token');
// Index single URL
$indexer->submitUrl('https://www.example.com/page');
// Index multiple URLs
$indexer->submitUrls([
'https://www.example.com/page1',
'https://www.example.com/page2'
]);
// Delete URL from index
$indexer->submitUrl('https://www.example.com/deleted-page', URLIndexingType::DELETE);
use Melbahja\Seo\Indexing\IndexNowIndexer;
$indexer = new IndexNowIndexer('your-indexnow-api-key');
// Submit to all supported engines
$indexer->submitUrl('https://www.example.com/page');
// Submit multiple URLs
$indexer->submitUrls([
'https://www.example.com/page1',
'https://www.example.com/page2'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.