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

4

11

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

Static answered 22/1, 2018 at 12:11 Comment(0)
B
43

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

Brezin answered 22/1, 2018 at 12:12 Comment(2)
I'm getting this error on Laravel 7.0.3. Did they remove it?Geffner
@Geffner - nope, but it seems they changed the API: laravel.com/docs/7.x/frontendBlakeley
S
8

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

Seeder answered 14/5, 2020 at 16:27 Comment(1)
This worked for me but i had to add --ignore-platform-reqs to the composer command to get past dependency errorsAdopt
B
4

In Laravel 7.x, the scaffolding API has changed:

php artisan ui react

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

Blakeley answered 6/3, 2020 at 3:35 Comment(0)
A
2

Laravel 5.5 a new Artisan preset command allows you to replace default tools with other tools like React, Bootstrap, and even removing all of it.

  1. The React preset command can be initialized through Artisan:

    php artisan preset react

  2. The Bootstrap preset is useful if you prefer not to use any JavaScript scaffolding at all, but still, want to keep the Bootstrap CSS.

    php artisan preset bootstrap

  3. The final preset option is “none” which will remove both Bootstrap and Vue.js:

    php artisan preset none

Allanson answered 26/1, 2018 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.