2017 © Pedro Pelรกez
 

library yard

Write ReactJS Component in PHP!

image

plansys/yard

Write ReactJS Component in PHP!

  • Friday, August 25, 2017
  • by plansys
  • Repository
  • 5 Watchers
  • 0 Stars
  • 47 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

, (*1)

Yard: ReactJS Component in PHP

This library allows you to write ReactJS Component in PHP Class., (*2)

It works by creating React Component on-the-fly based on javascript generated by PHP., (*3)

Vanilla PHP Installation

You can install Yard using composer:, (*4)

composer require plansys\yard

Follow these steps to use yard:, (*5)

  1. Create my-project directory
  2. Open terminal and execute composer require plansys\yard in that directory
  3. Create pages, tmp and redux directory in my-project directory
  4. Make sure /tmp directory is writeable by web server process (chmod 755 into this directory)
  5. Create base.php and index.php file

After those steps, your directory structure should look like this:, (*6)

my-project โ”œโ”€ tmp (writable) โ”œโ”€ pages โ”œโ”€ redux โ””โ”€ vendors โ”œโ”€ ... โ””โ”€ yard โ”œโ”€ base (copy to /bases/default) โ”œโ”€ src โ””โ”€ ... โ””โ”€ ... โ””โ”€ base.php โ””โ”€ index.php, (*7)

Put this code into base.php file: ```php <?php, (*8)

$host = str_replace("index.php", "", strtok($_SERVER["REQUEST_URI"], '?')); return [ 'name' => 'PLANSYS', 'offline' => false, 'settings' => null, 'host' => $host, 'modules' => [ '' => [ 'dir'=> dirname(FILE) . '/pages', 'url' => $host . '/pages', 'redux' => dirname(FILE) . '/redux' ] ], 'dir' => [ 'dir'=> dirname(FILE) . '/pages', 'base' => dirname(FILE) . '/vendor/plansys/yard/base/build', 'cache' => dirname(FILE) . '/tmp', 'root' => dirname(FILE) ], 'url' => [ 'base' => $host . '/vendor/plansys/yard/base/build', 'cache' => $host . '/tmp/[file]', 'page' => $host . '/index.php?p=[page]', ] ]; ```, (*9)

And put this code into index.php file:, (*10)

```php <?php, (*11)

require("vendor/autoload.php");, (*12)

$base = new \Yard\Base(dirname(FILE) . DIRECTORY_SEPARATOR . "base.php"); $yard = new \Yard\Renderer($base);, (*13)

$parr = explode('...', @$_GET['p']); $modearr = count($parr) > 1 ? explode(".", $parr[1]) : ['']; $mode = count($modearr) > 1 ? $modearr[1] : $modearr[0];, (*14)

if ($mode == 'css') { header('Content-type: text/css'); } else if (in_array($mode, ['js', 'jsdev', 'sw'])) { header('Content-type: text/javascript'); } $page = isset($_GET['p']) ? $_GET['p'] : 'builder:Index'; echo $yard->render($page);, (*15)

```, (*16)

Then open index.php in your browser., (*17)


Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY, (*18)

The Versions

25/08 2017

dev-master

9999999-dev

Write ReactJS Component in PHP!

  Sources   Download

MIT

The Requires

 

by Rizky

23/08 2017

0.0.5

0.0.5.0

Write ReactJS Component in PHP!

  Sources   Download

MIT

The Requires

 

by Rizky

19/08 2017

dev-dev

dev-dev

Write ReactJS Component in PHP!

  Sources   Download

MIT

The Requires

 

by Rizky

18/06 2017

0.0.3

0.0.3.0

Write ReactJS Component in PHP!

  Sources   Download

MIT

The Requires

 

by Rizky