Asked  2 Years ago    Answers:  5   Viewed   91 times

I'm using a shared hosting which uses cPanel as its control panel and within the cPanel public_html is the default root directory, because of this I can't get my Laravel application work properly.

Is there any way to make Laravel use public_html instead of public folder?



Quite easy to find this with a simple search.


In your index.php add the following 3 lines.

| 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';

// set the public path to this directory
$app->bind('path.public', function() {
    return __DIR__;


As Burak Erdem mentioned, another option (and more preferable) is to put this in the AppProvidersAppServiceProvider register() method.

 * Register any application services.
 * @return void
public function register()
    // ...

    $this->app->bind('path.public', function() {
        return base_path('public_html');
Tuesday, October 4, 2022


php.ini is searched for in these locations (in order):

  • SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
  • The PHPRC environment variable. Before PHP 5.2.0, this was checked after the registry key mentioned below.
  • As of PHP 5.2.0, the location of the php.ini file can be set for different versions of PHP. The following registry keys are examined in order:
    • [HKEY_LOCAL_MACHINESOFTWAREPHPx.y.z], [HKEY_LOCAL_MACHINESOFTWAREPHPx.y] and [HKEY_LOCAL_MACHINESOFTWAREPHPx], where x, y and z mean the PHP major, minor and release versions. If there is a value for IniFilePath in any of these keys, the first one found will be used as the location of the php.ini (Windows only).
    • [HKEY_LOCAL_MACHINESOFTWAREPHP], value of IniFilePath (Windows only).
  • Current working directory (except CLI).
  • The web server's directory (for SAPI modules), or directory of PHP (otherwise in Windows).
  • Windows directory (C:windows or C:winnt) (for Windows), or --with-config-file-path compile time option.

For CLI, your best bet is probably either to set the $PHPRC environment variable for the account that will be executing scripts, or recompile PHP with a different --with-config-file-path configuration setting.

You can also override the php.ini search dir on a per-execution basis by specifying the -c option when invoking PHP:

> php --help
Usage: php [options] [-f]  [--] [args...]
  -c | Look for php.ini file in this directory

Wednesday, October 12, 2022

You can use the following:

return Redirect::back()->withInput(Input::all());

If you're using Form Request Validation, this is exactly how Laravel will redirect you back with errors and the given input.

Excerpt from IlluminateFoundationValidationValidatesRequests:

return redirect()->to($this->getRedirectUrl())
                    ->withErrors($errors, $this->errorBag());
Wednesday, August 17, 2022

PHPWord is on Packagist, so installing it on Laravel is as easy as:

composer require phpoffice/phpword

or adding this to your composer.json then running composer install:

"require": {
   "phpoffice/phpword": "dev-master"

Once installed, you can use it in your code like this (taken from the documentation):

// Creating the new document...
$phpWord = new PhpOfficePhpWordPhpWord();

/* Note: any element you append to a document must reside inside of a Section. */

 // Adding an empty Section to the document...
$section = $phpWord->addSection();

// Adding Text element to the Section having font styled by default...
        '"Learn from yesterday, live for today, hope for tomorrow. '
            . 'The important thing is not to stop questioning." '
            . '(Albert Einstein)'

// Saving the document as HTML file...
$objWriter = PhpOfficePhpWordIOFactory::createWriter($phpWord, 'HTML');
Friday, September 2, 2022

Step 1: You have to enable .htaccess by adding this to your vhost:

<Directory /var/www/html/yourfoldername/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

Step 2: And disabled SELinux permanently. Click here

Saturday, September 24, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages