PHP code example of tonning / bladebook

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

    

tonning / bladebook example snippets




namespace App\Views\Components\Layouts;

use Illuminate\View\Component;

class Card extends Component
{
    public ?string $title = null;

    public function __construct(string $title = null)
    {
        $this->title = $title;
    }

    public function render()
    {
        return view('components.layouts.card');
    }
}

$this->callAfterResolving(BladebookComponentsFinder::class, function (BladebookComponentsFinder $bladebook) {
    $bladebook->registerBook(name: 'fabrick', bladeComponentNamespace: 'fab', namespace: 'App\Http\Bladebook');
});

$this->callAfterResolving(BladebookComponentsFinder::class, function (BladebookComponentsFinder $bladebook) {
    $bladebook->registerBook(name: 'fabrick', bladeComponentNamespace: 'fab', namespace: 'App\Http\Bladebook')
        ->registerStylePaths('/css/app.css')
        ->registerScriptPaths('/js/app.js');;
});

Gate::define('viewBladebook', function ($user) {
    return true;
});
bash
php artisan vendor:publish --provider="Tonning\Bladebook\BladebookServiceProvider" --tag="bladebook:assets"
bash
php artisan vendor:publish --provider="Tonning\Bladebook\BladebookServiceProvider" --tag="config"
bash
php artisan bladebook:discover