PHP code example of stringkey / bit-magic-bundle

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

    

stringkey / bit-magic-bundle example snippets


use Stringkey\BitMagicBundle\Form\BitMaskType;
use Stringkey\BitMagicBundle\Utilities\BitOperations;

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $choices = BitOperations::createOptions(16, 0xffff); // creates the choice fields

        /** @var BitmaskTest $bitmaskTest */
        $bitmaskTest = $builder->getData(); // fetch the entity
        $enableOption = ['enable_mask' => $bitmaskTest->getEnableMask(), 'choices' => $choices];

        $builder->add('enableMask', BitMaskType::class, ['choices' => $choices]);
        $builder->add('valueMask', BitMaskType::class, $enableOption);
    }
shell
php bin/console doctrine:database:create
shell
php bin/console make:entity BitmaskTest
shell
php bin/console doc:mig:diff
php bin/console doc:mig:mig
php bin/console make:crud BitmaskTest