S.M_Emamian
S.M_Emamian

Reputation: 17383

How to install laravel inside an addon domain

my project name is yadavarpro.

I created a yadavarpro folder behind of public_html and I copied all folders except public.

(I could not upload the image on StackOverflow!)

like this image:

http://yadavarpro.com/1.JPG

I created another yadavarpro folder inside public_html and copy all contents of public folder.

like this image:

http://yadavarpro.com/2.JPG

but my site show a white screen. I think I should change bootstrap configure. But I don't know.

http://yadavarpro.com/

Upvotes: 0

Views: 755

Answers (3)

S.M_Emamian
S.M_Emamian

Reputation: 17383

I solved:

edit index.php inside public_html/yadavarpro:

use:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../../yadavarpro/bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../../yadavarpro/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

instead of:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

Upvotes: 1

apokryfos
apokryfos

Reputation: 40681

What you are doing is highly unorthodox, but you may trick laravel into accepting it (probably not but worth trying).

I'll refer to 2 important files in the laravel boot procedure: the index and the app bootstrapper

Basically in the index there's a 2 references to __DIR__."../bootstrap" (one for the autoloader and one for the app) which you need to alter to find the actual bootstrap location. In your current structure that's probably: __DIR__."../yadavarpro/bootstrap" if I understand it correctly.

In the app bootstrapper you need to do:

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);
$app->instance("path.public",__DIR__."../../public_html"); //Basically overwrite the public path with whatever the correct one is.

This assumes that whoever needs to get the public path they will always get it via public_path or app()->make("path.public") and never assume that it is just base_path("public") however it's unlikely this assumption is never made in any part of Laravel or any module within so beware.

Upvotes: 0

user320487
user320487

Reputation:

You definitely need the public directory and all it's contents. As long as the addon domain points to the public laravel directory then it should work ok.

Upvotes: 0

Related Questions