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/

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I solved:

edit index.php inside public_html/yadavarpro:

use:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f7b6e7663607d4f636e7d6e796a63216c6062">[email protected]</a>>
 */

/*
|--------------------------------------------------------------------------
| 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(IlluminateContractsHttpKernel::class);

$response = $kernel->handle(
    $request = IlluminateHttpRequest::capture()
);

$response->send();

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

instead of:
<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b1f0a120704192b070a190a1d0e0745080406">[email protected]</a>>
 */

/*
|--------------------------------------------------------------------------
| 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(IlluminateContractsHttpKernel::class);

$response = $kernel->handle(
    $request = IlluminateHttpRequest::capture()
);

$response->send();

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

Method 2

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.

Method 3

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 IlluminateFoundationApplication(
    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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x