Laravel 5.4 can't run php artisan preset react
comand
Getting "Command "preset" is not defined." responde.
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
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
In Laravel 7.x, the scaffolding API has changed:
php artisan ui react
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.
The React preset command can be initialized through Artisan:
php artisan preset react
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
The final preset option is “none” which will remove both Bootstrap and Vue.js:
php artisan preset none
© 2022 - 2024 — McMap. All rights reserved.