简体   繁体   English

如何将 Laravel 项目与 reactJs 项目链接在一起

[英]How to link laravel project with reactJs project together

my main idea is to have two separate projects.我的主要想法是有两个独立的项目。 One for backend that uses laravel and one for frontend that uses react js.一种用于使用 laravel 的后端,一种用于使用 react js 的前端。 Is there a way that i can link them together?有没有办法可以将它们链接在一起? i googled the answer, but i couldn't find anything helpful.我用谷歌搜索了答案,但我找不到任何有用的东西。

Use ziggy library .It will map all your laravel routes names an their url(s).使用 ziggy 库。它会映射你所有的 Laravel 路由名称和它们的 url(s)。

Ziggy provides a JavaScript route() helper function that works like Laravel's, making it easy to use your Laravel named routes in JavaScript. Ziggy 提供了一个 JavaScript route() 辅助函数,其工作方式与 Laravel 类似,从而可以轻松地在 JavaScript 中使用 Laravel 命名路由。

Make root folder like website then open-shell inside of website folder in enter commands:像网站一样制作根文件夹,然后在输入命令中打开网站文件夹内的外壳:

composer create-project laravel/laravel LaravelAPIs

then for react client:然后对于反应客户端:

npx create-react-app ReactClient

then your website folder will contain two folders那么您的网站文件夹将包含两个文件夹

/website
    /LaravelAPIs
    /ReactClient

then run laravel app on port 8000 and react app run on 3000 port然后在端口 8000 上运行 laravel 应用程序并在 3000 端口上运行反应应用程序

/website/LaravelAPIs/>php artisan serve
/website/ReactClient/>npm start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM