PHP code example of wangta69 / laravel-meta

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

    

wangta69 / laravel-meta example snippets


Meta::set('market.item', ['item' => (string)$item->id])
    ->title($item->name)
    ->description($item->short_desc)
    // 2차원 배열에서 특정 키값을 추출하여 키워드로 자동 변환
    ->extractKeywordsFromArray($item->tags, 'tag')
    ->image(\Storage::url($item->image))
    ->update();

// Controller
$meta = Meta::get()->title($request->q . ' 검색결과');

return view('search', compact('meta'));

$meta->smartDescription(
    "사주 분석 결과.",
    $charms, // 배열 데이터
    "숨겨진 매력 포인트(:data) 확인!", // 데이터 존재 시에만 문구 삽입
    "지금 바로 확인해보세요."
);

Meta::get()->suffix(function($suffix) use($page) {
    $suffix->title = ' - ' . $page . '페이지';
});

Meta::get()
    ->type('Person')
    ->structuredData([
        'name' => '스타 이름',
        'jobTitle' => '가수',
        'memberOf' => ['@type' => 'Organization', 'name' => '그룹명']
    ])
    ->faq(function($meta) {
        $meta->addFaq("질문 내용", "답변 내용");
    });

Meta::get()->image('/path/to/image.jpg');

Meta::get()->create_image(function($image) {
    $image->save_path = 'public/meta/banner.png'; // 저장 경로
    $image->background_image = public_path('images/bg.jpg'); // 배경
    $image->font = public_path('fonts/Nanum.ttf'); // 폰트
    $image->fontSize = 25; // 크기
    $image->create();
});
html
<!-- 헤더 영역: 메타 태그, OG, Twitter, JSON-LD 자동 출력 -->
<x-pondol-meta::meta :meta="$meta" />

<!-- 본문 영역: 네이버/빙 등 검색엔진 자동 색인(IndexNow) 및 인증 처리 -->
<x-pondol-meta::indexnow-auth :meta="$meta ?? null" />