Troubleshooting Laravel 5.4 Can’t Run “php artisan preset react” Command

Laravel 5.4 Can’t Run “php artisan preset react” Command If you’re encountering an issue with running the “php artisan preset react” command in Laravel 5.4, you are not alone. The error message “Command ‘preset’ is …

title_thumbnail(Troubleshooting Laravel 5.4)

Laravel 5.4 Can’t Run “php artisan preset react” Command

If you’re encountering an issue with running the “php artisan preset react” command in Laravel 5.4, you are not alone. The error message “Command ‘preset’ is not defined” can be frustrating, but there are solutions available to help you overcome this problem.

For Laravel 7+ Projects

If you’re working with Laravel 7 or higher, you’ll need to follow these steps:

composer require laravel/ui
php artisan ui react

This will install the necessary dependencies and set up the React preset for your Laravel project. For more detailed information, you can refer to the Laravel documentation on frontend preset.

For Laravel 5.5+ Projects

If you’re running Laravel 5.5 or a newer version, you can use the following command:

php artisan preset react

This command will apply the React preset to your Laravel project. You can find additional details in the Medium article by Taylor Otwell discussing Laravel frontend presets.

Steps to Run React in Laravel 7.x and 8.x

If you want to run React in Laravel 7.x and 8.x, follow the steps below:

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

After running these commands, you can add the React Developer Chrome extension to check if your application is using React. Additionally, ensure you’ve included the required lines of code in your welcome.blade.php file.

Changes in Laravel 7.x Scaffolding API

It’s important to note that the scaffolding API has changed in Laravel 7.x. To apply the React preset in Laravel 7.x, use the following command:

php artisan ui react

You can find further information in the Laravel documentation on frontend scaffolding.

Using Artisan Preset Commands in Laravel 5.5

In Laravel 5.5, there’s a convenient Artisan preset command to replace default tools with alternatives like React, Bootstrap, or even to remove them entirely.

To initialize the React preset command, use the following Artisan command:

php artisan preset react

Similarly, you can use the following commands to apply the Bootstrap or “none” (to remove Bootstrap and Vue.js) presets:

php artisan preset bootstrap
php artisan preset none

These commands allow you to customize the tools used in your Laravel project.

By following these steps and using the appropriate commands, you should be able to resolve the issue and run the “php artisan preset react” command successfully in your Laravel 5.4 or newer project.

Don’t let the “Command ‘preset’ is not defined” error discourage you – with the right approach, you can harness the power of React within your Laravel application!

reference :

https://stackoverflow.com/questions/48381322/laravel-5-4-cant-run-php-artisan-preset-react-comand

Read Another Article :

reactjs

Leave a Comment