PHP code example of makraz / ux-vvvebjs

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

    

makraz / ux-vvvebjs example snippets


use Makraz\VvvebJsBundle\Form\VvvebJsType;

public function buildForm(FormBuilderInterface $builder, array $options): void
{
    $builder
        ->add('content', VvvebJsType::class)
    ;
}

use Makraz\VvvebJsBundle\Form\VvvebJsType;
use Makraz\VvvebJsBundle\DTO\Enums\VvvebJsComponentGroup;

$builder->add('content', VvvebJsType::class, [
    'vvvebjs_components' => [
        VvvebJsComponentGroup::COMMON,
        VvvebJsComponentGroup::BOOTSTRAP5,
        VvvebJsComponentGroup::EMBEDS,
    ],
]);

'vvvebjs_components' => ['common', 'bootstrap5', 'embeds'],

use Makraz\VvvebJsBundle\Form\VvvebJsType;
use Makraz\VvvebJsBundle\DTO\Enums\VvvebJsPlugin;

$builder->add('content', VvvebJsType::class, [
    'vvvebjs_plugins' => [
        VvvebJsPlugin::CODE_MIRROR,
        VvvebJsPlugin::GOOGLE_FONTS,
        VvvebJsPlugin::AOS,
        VvvebJsPlugin::JSZIP,
    ],
]);

$builder->add('content', VvvebJsType::class, [
    'vvvebjs_options' => [
        'height' => '800px',
        'border' => true,
        'designerMode' => false,
        'readOnly' => false,
        'uploadUrl' => '/vvvebjs/upload',
    ],
]);

use Makraz\VvvebJsBundle\Form\VvvebJsAdminField;

public function configureFields(string $pageName): iterable
{
    yield VvvebJsAdminField::new('content');
}

use Makraz\VvvebJsBundle\DTO\Enums\VvvebJsComponentGroup;
use Makraz\VvvebJsBundle\DTO\Enums\VvvebJsPlugin;

yield VvvebJsAdminField::new('content')
    ->setFormTypeOptions([
        'vvvebjs_components' => [
            VvvebJsComponentGroup::COMMON,
            VvvebJsComponentGroup::BOOTSTRAP5,
        ],
        'vvvebjs_plugins' => [
            VvvebJsPlugin::CODE_MIRROR,
            VvvebJsPlugin::GOOGLE_FONTS,
        ],
        'vvvebjs_options' => [
            'height' => '700px',
            'uploadUrl' => '/vvvebjs/upload',
        ],
    ])
;

$builder->add('content', VvvebJsType::class, [
    'vvvebjs_options' => [
        'uploadUrl' => '/vvvebjs/upload',
    ],
]);

use Makraz\VvvebJsBundle\Upload\UploadHandlerInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;

class MyUploadHandler implements UploadHandlerInterface
{
    public function upload(UploadedFile $file): string
    {
        // Your upload logic here
        // Return the public URL of the uploaded file
        return 'https://example.com/path/to/file.jpg';
    }
}
yaml
# config/routes/vvvebjs.yaml
vvvebjs:
    resource: '@VvvebJsBundle/config/routes.php'