Angular 4如何与Laravel 5.5一起使用? [英] How can Angular 4 use with Laravel 5.5 together?

查看:70
本文介绍了Angular 4如何与Laravel 5.5一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道angular可以与某些框架集成.我想在Laravel 5.5中使用角度版本4,但是我不知道如何设置应用程序.是否有可能将角度CLI安装到Laravel项目中?哪种解决方案最适合构建带有角度的应用程序(与框架集成或单独的两个项目)?

I know that angular can integrate with some frameworks. I want to use angular version 4 into Laravel version 5.5 but I don't know how to setup the application. It is possible that I install angular CLI into Laravel project? Which solutions is the best for building app with angular ( integrate with framework or separate two projects)?

推荐答案

我假设您对Angular和Laravel有所了解.

I am assuming you have the understanding about Angular and Laravel.

我在许多项目中都使用过Angular(2+)和Laravel. Angular用于前端开发,Laravel用于后端API.

I have used Angular(2+) and Laravel in many projects. Angular is for front-end development and Laravel for backend API.

集成Laraval和Angular非常容易.

It is very easy to integrate both Laraval and Angular.

Laravel项目中有"resources"目录.在其中,我曾经保留了Angular代码.

There is "resources" directory in Laravel project. inside this, I used to keep the Angular code.

使用" ng build "命令,这将创建一个" dist "目录. 此目录保留您的所有文件(javascript,CSS,图像和索引文件).

Use "ng build" command, this will create a "dist" directory. This directory keeps your all files(javascript, CSS, images and index file).

Laravel通过Laravel项目根目录中的"公共"文件夹提供应用程序.

Laravel serves the app from "public" folder in the root directory of Laravel project.

将" dist "(使用"ng build"命令创建的)文件夹放置在" public "目录中.

Place the "dist" (that was created using "ng build" command) folder inside "public" directory.

如果使用Apache Web服务器,则将公用文件夹设置为根文件夹,并在" .htaccess "文件内添加重写规则.

if using Apache web server then set the public folder as a root folder and add a rewrite rule inside ".htaccess" file.

RewriteEngine开启

RewriteRule index.html index.php

现在服务器将读取我们放置在公用文件夹中的" index.html "文件.

Now server will read "index.html" file that we place inside the public folder.

这篇关于Angular 4如何与Laravel 5.5一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆