Indicate the base_path () correctly in Laravel 5.6

1

I'm doing tests on deploy .

A few days ago I did it in the following way, I uploaded the files in my CPanel hosting to the root, that is, /home/miproyecto and that of the public folder in /home/miproyecto/public_html , I made the adjustment of the new public route en AppServiceProviders.php .

$this->app->bind('path.public', function() {
            return base_path('public_html');
        });

Everything worked fine, even the images I upload do it correctly inside the public folder.

Today I did it in the same way, except that instead of uploading the project to /home/miproyecto , I did it in /home/miproyecto/laravel for more organization.

I also made adjustments to indicate the public folder and everything works fine, except now the base_path , instead of remaining in /home/miproyecto remains in /home/miproyecto/laravel .

Now when uploading images instead of being saved in /home/miproyecto/public_html/img upload to /home/miproyecto/laravel/public_html/img

In the index.php I made the adjustments so that the route of the project is recognized

require __DIR__ . '/../laravel/vendor/autoload.php';
$app = require_once __DIR__ . '/../laravel/bootstrap/app.php';
    
asked by Christian Patiño 20.08.2018 в 19:12
source

1 answer

0

It was fixed, my mistake was to return the route from the AppServiceProvider.php, it should be as follows

public function register()
    {
       $this->app->bind('path.public', function() {
            return base_path().'/../public_html'; // Forma correcta para mi caso
            //return base_path() . '/public_html'; // Forma incirrecta
        });
    }
    
answered by 20.08.2018 в 19:33