PHP code example of krisnaxyoga / krisna-crud-gen

1. Go to this page and download the library: Download krisnaxyoga/krisna-crud-gen 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/ */

    

krisnaxyoga / krisna-crud-gen example snippets




namespace App\CrudSchemas;

use App\Models\Product;
use Krisnaxyoga\CrudGen\Attributes\ApiResource;
use Krisnaxyoga\CrudGen\Fields\{TextField, NumberField, SelectField};
use Krisnaxyoga\CrudGen\Resource;

#[ApiResource(slug: 'products', perPage: 25)]
class ProductResource extends Resource
{
    public function model(): string
    {
        return Product::class;
    }

    public function fields(): array
    {
        return [
            TextField::make('name')->

TextField::make('title')->->options(['admin' => 'Admin', 'user' => 'User'])->multiple();
NumberField::make('price')->min(0)->step(0.01);
FileUploadField::make('image')->image()->disk('public')->directory('products')->maxKb(2048);
BelongsToField::make('category_id')->relation(Category::class, 'name');
RichTextField::make('body');

return [
    // api | blade | vue | react | svelte  (route admin nonaktif saat 'api')
    'frontend' => env('CRUD_ENGINE_FRONTEND', 'api'),

    'api'   => ['prefix' => 'api/crud', 'middleware' => ['api', 'auth:sanctum']],
    'admin' => [
        'prefix'     => 'admin',
        'middleware' => ['web', 'auth'],
        'theme'      => env('CRUD_ENGINE_THEME', 'light'),   // tema DaisyUI
        'brand'      => env('CRUD_ENGINE_BRAND', 'CRUD Engine'),
    ],
    'schema_path'      => app_path('CrudSchemas'),
    'schema_namespace' => 'App\\CrudSchemas',
];
bash
php artisan crud:install
bash
php artisan crud:install --frontend=api                    # hanya REST API (paling ringan)
php artisan crud:install --frontend=blade                  # Admin Panel server-side (tanpa npm/build)
php artisan crud:install --frontend=vue                    # Admin Panel Inertia + Vue
php artisan crud:install --frontend=react                  # Admin Panel Inertia + React
php artisan crud:install --frontend=svelte                 # Admin Panel Inertia + Svelte
php artisan crud:install --frontend=blade --theme=dracula  # sekaligus set tema DaisyUI
bash
php artisan install:api
bash
php artisan vendor:publish --tag=crud-engine-config
bash
php artisan crud:eject products            # generate controller + request + routes
php artisan crud:eject products --force     # timpa
php artisan crud:eject products --purge     # + hapus schema
bash
php artisan crud:install --frontend=blade
bash
php artisan crud:install --frontend=react
bash
php artisan vendor:publish --tag=crud-engine-vue      # atau -react / -svelte
php artisan vendor:publish --tag=crud-engine-assets   # CSS saja