Laravel 5.4 无法运行“php artisan preset react”命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48381322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:16:45  来源:igfitidea点击:

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

reactjslaravellaravel-5preset

提问by Vardan

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

Laravel 5.4 无法运行php artisan preset react命令并获取“未定义命令“预设”。回应。

回答by Alexey Mezenin

For Laravel 7+ projects:

对于 Laravel 7+ 项目:

composer require laravel/ui
php artisan ui react

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

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

For Laravel 5.5+ projects:

对于 Laravel 5.5+ 项目:

php artisan preset react

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

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

回答by Shivam Chhetri

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.

Laravel 5.5 新的 Artisan 预设命令允许您用其他工具替换默认工具,例如 React、Bootstrap,甚至删除所有这些工具。

  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

  1. React 预设命令可以通过 Artisan 进行初始化:

    php工匠预设反应

  2. 如果您根本不想使用任何 JavaScript 脚手架,但仍希望保留 Bootstrap CSS,则 Bootstrap 预设非常有用。

    php artisan 预设引导程序

  3. 最后一个预设选项是“none”,它将删除 Bootstrap 和 Vue.js:

    php工匠预设无

回答by ortonomy

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

在 Laravel 7.x 中,脚手架 API 发生了变化:

php artisan ui react

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

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

回答by Rashi Goyal

Steps to run React in 7.x in laravel

在 7.x 中在 laravel 中运行 React 的步骤

composer require laravel/ui
php artisan ui react
npm install
npm 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

要检查是否在 laravel 项目上运行 react,您可以添加 React Developer Chrome 扩展程序并将鼠标悬停在图标上。它将显示应用程序正在使用反应。然后做

php artisan serve

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

并在您的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

在关闭 body 标签后添加以下行

<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

并删除定义的完整样式刷新您的 Laravel 页面,然后将鼠标悬停在添加到 chrome 中的 react 扩展上,它将显示该页面正在使用 React JS。成功加载 ReactDOM。希望这有助于运行基本的 laravel + react 欢迎页面