Prasanna Prasanna - 11 months ago 54
PHP Question

Integrating existing project by laravel framework?

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 me out.

Answer Source

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

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.

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:

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

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]

Then you can have your URLs:




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

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

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

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

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

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) Create a whole new Laravel project and bring your legacy code into your Laravel application, which is, blasically, create an application from scratch.