Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.4 can't run "php artisan preset react" comand

Laravel 5.4 can't run php artisan preset react comand Getting "Command "preset" is not defined." responde.

like image 994
Vardan Avatar asked Jan 22 '18 12:01

Vardan


2 Answers

For Laravel 7+ projects:

composer require laravel/ui
php artisan ui react

https://laravel.com/docs/7.x/frontend#introduction

For Laravel 5.5+ projects:

php artisan preset react

https://medium.com/@taylorotwell/laravel-frontend-presets-eca312958def

like image 128
Alexey Mezenin Avatar answered Oct 12 '22 13:10

Alexey Mezenin


Steps to run React in 7.x and 8.x in laravel

composer require laravel/ui
php artisan ui react
npm install
npm run dev

To check if for react working on laravel project you can add React Developer Chrome extension and hover on to the icon. It will show that application is using react. Then do

php artisan serve

and add below lines in your head of welcome.blade.php

<link href="/css/app.css" rel="stylesheet" />

Add Below line in your body tag

<div id="example"></div>

Add below line after closing body tag

<script src="/js/app.js"></script>

and remove the defined complete style Refresh your laravel page and hen you will hover on the extension for react which is added in chrome it will show that the page is using React JS. Successfully the ReactDOM is loaded. Hope this helps to run a basic laravel + react welcome page

like image 43
Rashi Goyal Avatar answered Oct 12 '22 14:10

Rashi Goyal