Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating existing project by laravel framework?

Tags:

php

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.

like image 404
Prasanna Avatar asked Apr 25 '14 12:04

Prasanna


2 Answers

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
</Directory>

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>

Then you can have your URLs:

http://myapp

and

http://myapp/subapp

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.

like image 135
Antonio Carlos Ribeiro Avatar answered Oct 07 '22 23:10

Antonio Carlos Ribeiro


Go to your www folder

cd /var/www

Git clone your application (note that here the directory mustn't exist):

git clone https://github.com/antonioribeiro/application

Change directory to folder

cd application

Execute composer update (if you are in a development environment)

composer update

Or execute composer install (if you are in a production environment)

composer install

Note that for composer install or composer update, the folder may actually have files and even a vendor folder created, there is not such obstacle.

like image 30
Jonathan Cervantes Avatar answered Oct 07 '22 23:10

Jonathan Cervantes