2017 © Pedro Peláez
 

cakephp-plugin pack

CakePHP3 variables in JS

image

tutida/pack

CakePHP3 variables in JS

  • Thursday, September 8, 2016
  • by tutida
  • Repository
  • 0 Watchers
  • 6 Stars
  • 7,072 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 51 % Grown

The README.md

Pack plugin is for CakePHP3

You can easy to pass CakePHP4 variables to JS in View., (*1)

Requirements

  • PHP >= 7.0
  • CakePHP >= 4.0

Installation

In Application.php, (*2)

<?php
    $this->addPlugin('Pack');

In controller., (*3)

loadComponent('Pack.Pack');
        }
        ...
    }
```

In layout php or template php.

```php
    = $this->Pack->render();?>

Usage

Just set variables in your controller., (*4)

<?php

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

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

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

Just get the variables in your JS in view., (*5)

    Pack.entity;
    Pack.array;

Methods

  1. set($varName, $variable) … Set variable in Pack.
  2. remove($varNamee) … Remove variable in Pack.
  3. show() … Show all variable in Pack.
  4. rename($namespace) … Change Pack's namespace in JS.

example, (*6)

In controller, (*7)

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

In js, (*8)

    Hoge.array;

The Versions

08/09 2016

dev-master

9999999-dev

CakePHP3 variables in JS

  Sources   Download

The Requires

 

08/09 2016

1.0.1

1.0.1.0

CakePHP3 variables in JS

  Sources   Download

The Requires

 

07/09 2016

1.0.0

1.0.0.0

CakePHP3 variables in JS

  Sources   Download

The Requires

 

02/08 2016

0.5

0.5.0.0

CakePHP3 variables in JS

  Sources   Download

The Requires

 

The Development Requires

22/07 2016

0.3

0.3.0.0

CakePHP3 variables in JS

  Sources   Download

The Requires

 

The Development Requires