All Projects → talyssonoc → React Laravel

talyssonoc / React Laravel

Package for using ReactJS with Laravel

Projects that are alternatives of or similar to React Laravel

Acwa book ru
Книга "Архитектура сложных веб-приложений. С примерами на Laravel"
Stars: ✭ 886 (-2.32%)
Mutual labels:  laravel
Laravel Cookie Consent
Make your Laravel app comply with the crazy EU cookie law
Stars: ✭ 895 (-1.32%)
Mutual labels:  laravel
Laravel Angular6 Material
Laravel 5.6 + Angular 6 + Material Design single page application
Stars: ✭ 19 (-97.91%)
Mutual labels:  laravel
Laravel Jsonapi
Basic setup framework for creating a Laravel JSON-API server
Stars: ✭ 16 (-98.24%)
Mutual labels:  laravel
Laravel Bigbluebutton
A BigBlueButton API wrapper for Laravel 5
Stars: ✭ 17 (-98.13%)
Mutual labels:  laravel
Prerendercloud Nodejs
Express/Connect middleware for prerendering javascript-rendered pages with https://www.prerender.cloud for isomorphic/universal server side rendering
Stars: ✭ 18 (-98.02%)
Mutual labels:  server-side-rendering
Laravel Collectable
Stars: ✭ 7 (-99.23%)
Mutual labels:  laravel
Simple Cache
An easy to use Caching trait for Laravel's Eloquent Models.
Stars: ✭ 19 (-97.91%)
Mutual labels:  laravel
Identity Number
Validator for Swedish personal identity numbers (personnummer). For use "standalone" or with Laravel.
Stars: ✭ 17 (-98.13%)
Mutual labels:  laravel
Aliyun Sts
基于阿里云openapi系列接口中STS最新版本的SDK进行封装的composer package,解耦其他产品SDK,各个产品SDK功能使用组件化加载,减少代码臃肿。
Stars: ✭ 19 (-97.91%)
Mutual labels:  laravel
Laravel Collection Macros
Custom Laravel Collection Macros.
Stars: ✭ 17 (-98.13%)
Mutual labels:  laravel
Angular5.2 Laravel5.6
Angular 5.2 and Laravel 5.6 Authentication and CRUD
Stars: ✭ 17 (-98.13%)
Mutual labels:  laravel
Lvartisan
Laravel artisan command for creating view.
Stars: ✭ 18 (-98.02%)
Mutual labels:  laravel
Laravel Bootstrap Table List
Bootstrap table list generator for Laravel.
Stars: ✭ 16 (-98.24%)
Mutual labels:  laravel
Laravel Log
Simple API to write logs for Laravel.
Stars: ✭ 19 (-97.91%)
Mutual labels:  laravel
Laravel Stager
Laravel Stager State Machine, Its purpose is to add state machine functionality to models
Stars: ✭ 16 (-98.24%)
Mutual labels:  laravel
Laravel Docker Elasticsearch
This is a simple repo for practicing elasticsearch with laravel and docker.
Stars: ✭ 18 (-98.02%)
Mutual labels:  laravel
Eloquent Ldap
A Laravel 5.1 package that first tries to log the user against the internal database if that fails, it tries against the configured LDAP/AD server.
Stars: ✭ 19 (-97.91%)
Mutual labels:  laravel
Flox
Self Hosted Movie, Series and Anime Watch List
Stars: ✭ 901 (-0.66%)
Mutual labels:  laravel
Modules
📦 Modules package for Laravel
Stars: ✭ 900 (-0.77%)
Mutual labels:  laravel

Code Climate Build Status

react-laravel

With react-laravel you'll be able to use ReactJS components right from your Blade views, with optional server-side rendering, and use them on the client-side with React due to unobtrusive JavaScript.

Installation

V8js dependency

It's important to know that react-laravel has an indirect dependency of the v8js PHP extension.

You can see how to install it here: how to install v8js.

Composer

Set the minimum-stability of your composer.json to dev, adding this:

  "minimum-stability": "dev"

Then run:

  $ composer require talyssonoc/react-laravel:0.11

After that you should add this to your providers at the config/app.php file of your Laravel app:

  'React\ReactServiceProvider'

And then run:

  php artisan vendor:publish

And the react.php file will be available at the config folder of your app.

Usage

After the installation and configuration, you'll be able to use the @react_component directive in your views.

The @react_component directive accepts 3 arguments:

  @react_component(<componentName>[, props, options])

  //example
  @react_component('Message', [ 'title' => 'Hello, World' ], [ 'prerender' => true ])

  // example using namespaced component
  @react_component('Acme.Message', [ 'title' => 'Hello, World' ], [ 'prerender' => true ])
  • componentName: Is the name of the global variable that holds your component. When using Namespaced Components you may use dot-notation for the component name.
  • props: Associative of the props that'll be passed to your component
  • options: Associative array of options that you can pass to the react-laravel:
    • prerender: Tells react-laravel to render your component server-side, and then just mount it on the client-side. Default to true.
    • tag: The tag of the element that'll hold your component. Default to 'div'.
    • html attributes: Any other valid HTML attribute that will be added to the wrapper element of your component. Example: 'id' => 'my_component'.

All your components should be inside public/js/components.js (you can configure it, see below) and be global.

You must include react.js, react-dom.js and react_ujs.js (in this order) in your view. You can concatenate these files together using laravel-elixir.

react-laravel provides a ReactJS installation and the react_us.js file, they'll be at public/vendor/react-laravel folder after you install react-laravel and run:

  $ php artisan vendor:publish --force

For using the files provided by react-laravel and your components.js file, add this to your view:

  <script src="{{ asset('vendor/react-laravel/react.js') }}"></script>
  <script src="{{ asset('vendor/react-laravel/react-dom.js') }}"></script>
  <script src="{{ asset('js/components.js') }}"></script>
  <script src="{{ asset('vendor/react-laravel/react_ujs.js') }}"></script>

If you'll use a different version from the one provided by react-laravel (see composer.json), you got to configure it (see below).

Configurations

You can change settings to react-laravel at the config/react.php file:

  return [
    'source' => 'path_for_react.js',
    'dom-source' => 'path_for_react-dom.js',
    'dom-server-source' => 'path_for_react-dom-server.js',
    'components' => [ 'path_for_file_containing_your_components.js' ]
  ];

All of them are optional.

  • source: defaults to public/vendor/react-laravel/react.js.
  • dom-source: defaults to public/vendor/react-laravel/react-dom.js.
  • dom-server-source: defaults to public/vendor/react-laravel/react-dom-server.js.
  • components: defaults to public/js/components.js. Multiple components files may be specified here.

Your components.js file(s) should also be included at your view, and all your components must be at the window object.

Thanks

This package is inspired at react-rails.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].