Vardan
Vardan

Reputation: 143

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.

Upvotes: 11

Views: 21971

Answers (4)

Rashi Goyal
Rashi Goyal

Reputation: 941

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

Upvotes: 8

Alexey Mezenin
Alexey Mezenin

Reputation: 163848

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

Upvotes: 43

ortonomy
ortonomy

Reputation: 692

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

php artisan ui react

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

Upvotes: 4

Shivam Chhetri
Shivam Chhetri

Reputation: 697

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

Upvotes: 2

Related Questions