Asked  7 Months ago    Answers:  5   Viewed   39 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');
Wednesday, March 31, 2021
answered 7 Months ago

Run php artisan make:provider ExtendedXeroServiceProvider

Add it to ./config/app.php under providers

Open ./app/Providers/ExtendedXeroServiceProvider.php

Change extends ServiceProvider to extends XeroServiceProvider

Add use DrawMyAttentionXeroLaravelProvidersXeroServiceProvider to it as well

Add the original service provider to the discovery blacklist in ./composer.json


as of the time of writing, the drawmyattention/xerolaravel package does not use autodiscovery, but in the event that it does, this can be added to the composer.json:

"extra": {
    "laravel": {
        "dont-discover": [
Wednesday, March 31, 2021
answered 7 Months ago

Keep your session and cache separate.

In the file configdatabase.php

You can set many redis connections, by default there is a "default" but you can add more to it

let's say you created 'session-connection' and 'cache-connection'

now you need to make use of it

go to file 'configsession.php'

and set it to 'connection' => 'session-connection',

then go to file configcache.php

and set it to

    'redis' => [
        'driver'     => 'redis',
        'connection' => 'cache-connection',

and now you can get your redis session records.

use IlluminateSupportFacadesRedis;
Log::debug( Redis::connection('session-connection')->keys('*') );
Saturday, May 29, 2021
answered 5 Months ago

You can change your password reset email subject, but it will need some extra work. First, you need to create your own implementation of ResetPassword notification.

Create a new notification class insideappNotifications directory, let's named it ResetPassword.php:


namespace AppNotifications;

use IlluminateNotificationsNotification;
use IlluminateNotificationsMessagesMailMessage;

class ResetPassword extends Notification
    public $token;

    public function __construct($token)
        $this->token = $token;

    public function via($notifiable)
        return ['mail'];

    public function toMail($notifiable)
        return (new MailMessage)
            ->subject('Your Reset Password Subject Here')
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url('password/reset', $this->token))
            ->line('If you did not request a password reset, no further action is required.');

You can also generate the notification template using artisan command:

php artisan make:notification ResetPassword

Or you can simply copy-paste the above code. As you may notice this notification class is pretty similar with the default IlluminateAuthNotificationsResetPassword. You can actually just extend it from the default ResetPassword class.

The only difference is here, you add a new method call to define the email's subject:

return (new MailMessage)
        ->subject('Your Reset Password Subject Here')

You may read more about Mail Notifications here.

Secondly, on your appUser.php file, you need to override the default sendPasswordResetNotification() method defined by IlluminateAuthPasswordsCanResetPassword trait. Now you should use your own ResetPassword implementation:


namespace App;

use IlluminateNotificationsNotifiable;
use IlluminateFoundationAuthUser as Authenticatable;
use AppNotificationsResetPassword as ResetPasswordNotification;

class User extends Authenticatable
    use Notifiable;


    public function sendPasswordResetNotification($token)
        // Your your own implementation.
        $this->notify(new ResetPasswordNotification($token));

And now your reset password email subject should be updated!

Reset password email subject updated

Hope this help!

Wednesday, July 28, 2021
answered 3 Months ago

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');
Tuesday, August 10, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :