通过laravel框架集成现有项目? [英] Integrating existing project by laravel framework?

查看:53
本文介绍了通过laravel框架集成现有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从github克隆了一个项目,现在我需要集成该项目,因此如何使用laravel框架,我需要创建一个新项目然后需要替换文件夹吗?或其他替代方法?因为我是这个框架的新手.请帮帮我.

I have cloned a project from github and now i need to integrate that project, so how to do with laravel framework,Should i need to create a new project then need to replace folders?or any other alternatives? becuase i am new to this framework..help me out.

推荐答案

这是一个广泛的问题,因为它取决于您的项目,在这里我们不知道.

This is a broad question, because it depends on your project, which we don't know here.

Laravel不在乎您的项目文件在哪里,它使您可以自由地对所有文件进行所需的操作;人们在与Laravel应用程序共享文件夹的非Laravel项目中遇到的大多数问题都与虚拟主机,.htaccess配置和/或他们试图集成的应用程序有关.您必须非常了解这些Web服务器的工作原理,才能使您的项目在Laravel应用程序中正常运行.

Laravel doesn't care about where your project files are, it allows you freely to do whatever you need with all of them; most problems people have with non-Laravel projects sharing a folder with a Laravel application are related to virtual host, .htaccess configuration and/or the application they are trying to integrate. You have to understand very well how those web server things work to make your project play nicely with a Laravel application.

我的建议是:在项目内部创建一个子文件夹,并在其上构建Laravel应用程序.配置虚拟主机别名,将您的Laravel应用程序的基本URL指向该文件夹,您应该会很好.例如:

My advice is: create a subfolder inside your project and build your Laravel application on it. Configure a Virtual Host alias pointing the base URL of your Laravel application to that folder and you should be good. For example:

这将是myapp的子应用程序(Laravel)的别名:

This would be an alias for a subapp (Laravel) of myapp:

Alias /subapp "/var/www/myapp/subapp/public"

<Directory /var/www/myapp/subapp>
  Options Indexes Includes FollowSymLinks MultiViews
  AllowOverride AuthConfig FileInfo
  Order allow,deny
  Allow from all
</Directory>

.htaccess:

And the .htaccess:

<IfModule mod_rewrite.c>
    #Options -MultiViews
    RewriteEngine On
    RewriteBase /

    RewriteRule ^(.*)/$ /$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /subapp/index.php?/$1 [L]
</IfModule>

然后您可以拥有自己的URL:

Then you can have your URLs:

http://myapp

http://myapp/subapp

您甚至可以通过直接在Laravel代码中要求它们来使Laravel导入某些类:

You can even make Laravel import some of your classes by requiring them directly in your Laravel code:

require "../../../classes/Class.php";

如果您的应用程序基于Laravel之类的Composer,则可以执行以下操作来自动加载类:

If your application is based on Composer like Laravel, you can autoload your classes, by doing:

require "../../../vendor/autoload.php";

但是,如果您需要Laravel和应用程序之间的真正集成,则有两个(或更多)选项:

But if you need real integration between Laravel and your application, you have two (or more) options:

1)将其中一个转换为API(或在其中创建一个API),并将另一个转换为该API的客户端.

1) Transform one of them in an API (or create an API inside it) and the other one in a client to this API.

2)创建一个全新的Laravel项目,并将您的旧代码带入Laravel应用程序,这是从头开始创建一个应用程序.

2) Create a whole new Laravel project and bring your legacy code into your Laravel application, which is, blasically, create an application from scratch.

这篇关于通过laravel框架集成现有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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