PHP code example of mischasigtermans / laravel-ogkit

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

    

mischasigtermans / laravel-ogkit example snippets


use Ogkit\Ogkit;

class ArticleController extends Controller
{
    public function show(Article $article, Ogkit $ogkit)
    {
        $ogkit->template('layered', [
            'title' => $article->title,
            'category' => $article->category->name,
            'image' => $article->featured_image_url,
        ]);

        return view('articles.show', compact('article'));
    }
}

use Ogkit\Ogkit;

class ArticlePage extends Component
{
    public function mount(Article $article, Ogkit $ogkit)
    {
        $ogkit->template('detailed', [
            'title' => $article->title,
            'readingTime' => $article->reading_time . ' min read',
            'category' => $article->category->name,
            'image' => $article->featured_image_url,
        ]);
    }
}

$ogkit->template('layered', [
    'title' => 'How to Build Great Products',
    'category' => 'Engineering',
    'image' => asset('images/hero.jpg'),
]);

$ogkit->template('bold', [
    'title' => 'My Page',
    'backgroundType' => 'boxes',
]);

$ogkit->template('split-title', [
    'title' => 'Hello World',
    'font' => 'Space Grotesk',
]);

$ogkit->template('wireframe-split', [
    'title' => 'My Article',
    'font' => 'Open Sans',
    'fontSecondary' => 'Besley',
]);

// config/ogkit.php
return [
    'api_key' => env('OGKIT_API_KEY'),
    'preview' => env('OGKIT_PREVIEW', false),
    'base_url' => env('OGKIT_BASE_URL', 'https://ogkit.dev'),

    'defaults' => [
        'template' => 'wireframe-split',
        'font' => 'Space Grotesk',
        'font_secondary' => 'Besley',
        'accent' => '#171717',
        'typography' => [
            'primary' => '#171717',
            'secondary' => '#8a8a8a',
        ],
        'background' => [
            'type' => 'boxes',
            'primary' => '#ffffff',
            'secondary' => '#f5f5f5',
        ],
    ],
];

use Ogkit\Ogkit;

public function show(Article $article, Ogkit $ogkit)
{
    // Set template from controller
    $ogkit->template('layered', ['title' => $article->title]);

    // Get image URL
    $url = $ogkit->imageUrl();
    $url = $ogkit->imageUrl('https://example.com/page');
    $url = $ogkit->imageUrl(version: 'v2');

    // Get complete meta tags HTML
    $meta = $ogkit->meta();
    $meta = $ogkit->meta(
        title: 'Page Title',
        description: 'Page description',
        pageUrl: 'https://example.com/page',
        version: 'v2'
    );

    // Get just the image meta tags
    $meta = $ogkit->imageMeta();
}

class ArticleController extends Controller
{
    public function show(Article $article, Ogkit $ogkit)
    {
        $ogkit->template('detailed', [
            'title' => $article->title,
            'readingTime' => $article->reading_time . ' min read',
            'category' => $article->category->name,
            'image' => $article->featured_image_url,
        ]);

        return view('articles.show', compact('article'));
    }
}

class ProductController extends Controller
{
    public function show(Product $product, Ogkit $ogkit)
    {
        $ogkit->template('default', [
            'title' => $product->name,
            'subtitle' => $product->short_description,
            'price' => '$' . number_format($product->price, 2),
            'fromPrice' => $product->compare_price
                ? '$' . number_format($product->compare_price, 2)
                : null,
            'image' => $product->featured_image_url,
        ]);

        return view('products.show', compact('product'));
    }
}

class ProfileController extends Controller
{
    public function show(User $user, Ogkit $ogkit)
    {
        $ogkit->template('centered-logo-avatar', [
            'title' => $user->name,
            'authorName' => '@' . $user->username,
            'authorImage' => $user->avatar_url,
            'logo' => asset('images/logo.svg'),
        ]);

        return view('profiles.show', compact('user'));
    }
}

class DocsController extends Controller
{
    public function show(string $section, string $page, Ogkit $ogkit)
    {
        $doc = Documentation::find($section, $page);

        $ogkit->template('documentation', [
            'overline' => $section,
            'title' => $doc->title,
            'subtitle' => $doc->description,
            'repository' => 'github.com/your-org/your-repo',
        ]);

        return view('docs.show', compact('doc'));
    }
}
bash
php artisan vendor:publish --tag=ogkit-config
js
content: [
    // ... your other paths
    './vendor/mischasigtermans/laravel-ogkit/resources/views/**/*.blade.php',
],
bash
php artisan vendor:publish --tag=ogkit-css