PHP code example of tutida / pack

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

    

tutida / pack example snippets



    $this->addPlugin('Pack');


    class AppController extends Controller
    {

        public function initialize()
        {
            $this->loadComponent('Pack.Pack');
        }
        ...
    }

    <?= $this->Pack->render();

    $this->Pack->rename('Hoge');
    $this->Pack->set('array', $array);



    $entity = $this->Hoge->get($id);
    $array  = [...];

    $this->Pack->set('entity', $entity);
    $this->Pack->set('array', $array);

    ## OR ##
    $this->Pack->set(compact('entity', 'array'));

js
    Pack.entity;
    Pack.array;
js
    Hoge.array;