Viewed   451 times

I'm trying to deploy my laravel (Laravel Framework 7.28.3) to Cpanel, but got a 404 error. I uploaded my project into /public_html, modified the index.php file to point to the correct files (as below). I think there must be some mistake in the index.php file but couldn't figure it out. This is my first time asking my question (after searching for it several times), so hope that I will get the answer!

require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

this is my file structure in File Manager:

 Answers

1

Deploy laravel application in Cpanel

  • Setup 1 : - upload file to Cpanel the root directory – not the public_html.

  • Setup 2 : - Open the that folder and MOVE the CONTENTS of the public folder to your cpanel’s public_html .

  • Setup 3 : - Navigate to the public_html folder and locate the index.php file. Right click on it and select Code Editor from the menu.

and change this line

require __DIR__.'/../folderName/vendor/autoload.php';
$app = require_once __DIR__.'/../folderName/bootstrap/app.php';

NOTE : - folderName here is in root where you laravel application stay

that's it now all your request will come inside public_html folder index.php and this file will include require __DIR__.'/../folderName/vendor/autoload.php; and run laravel application


Folder structure will look like

/laravel
/public_html/index.php

indside index.php

require __DIR__.'/../laravel/vendor/autoload.php';;
$app = require_once __DIR__.'/../laravel/bootstrap/app.php'; // here laravel is folder name
Saturday, December 3, 2022
 
gracebe
 
3

first check if your model login has a field password in the login database schema after that change this :

if (Auth::attempt(['username' => $request->get('username'), 'pw' => $request->get('password')])) {
    return redirect('RegView');
}

to:

if (Auth::attempt(['username' => $request->get('username'), 'password' => $request->get('password')])) {
    return redirect('RegView');
}

also go to your app/Http/Auth/LoginController.php and add this :

  /**
     * Get the login username to be used by the controller.
     *
     * @return string
     */
    public function username()
    {
        return 'username';
    }

and finally change this :

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => AppUser::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],

        'users' => [
            'driver' => 'eloquent',
            'model' => Applogin::class,
        ],

to this :

'providers' => [

        'users' => [
            'driver' => 'eloquent',
            'model' => Applogin::class,
        ],

check if there is any errors if the page refresh :

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

if you really want to use pw instead of password look at this answer : https://.com/a/39382427/4369087

Saturday, September 10, 2022
3

Make sure to get() the subpages as IlluminateSupportCollection and mapWithKeys() to reformat the results. Use toArray() to provide the format Nova assumes:

private function selectOptions(): array
{
    $subpages = DB::table('subpages')->get();
    return $subpages->mapWithKeys(function ($subpage) {
        return [$subpage->slug => $subpage->slug];
    })->toArray();
}

This is how the returned result should look like:

[
    'my-article-1' => 'my-article-1',
    'my-article-2' => 'my-article-2',
    'my-article-3' => 'my-article-3',
]
Thursday, September 1, 2022
 
talha_q
 
3

Decode to array and array_combine with the new keys.
Then loop the 'agent' and replace the keys again with array_combine.

$arr = json_decode($json, true);
$mainkeys = ["url", "secret_token", "agent"];
$subkeys = ["id", "quantity"];

$arr = array_combine(array_slice($mainkeys,0,count($arr)), $arr);

if(isset($arr["agent"])){
    foreach($arr["agent"] as &$val){
        $val = array_combine($subkeys, $val);
    }
}
unset($val); 

https://3v4l.org/mKePQ

array(3) {
  ["url"]=>
  string(26) "https://www.gosdoddgle.com"
  ["secret_token"]=>
  string(25) "stringstrinngstringstring"
  ["agent"]=>
  array(2) {
    [0]=>
    array(2) {
      ["id"]=>
      string(6) "sdsds1"
      ["quantity"]=>
      string(6) "sdsds1"
    }
    [1]=>
    &array(2) {
      ["id"]=>
      string(6) "sdsds1"
      ["quantity"]=>
      string(6) "sdsds1"
    }
  }
}
Tuesday, August 23, 2022
4

The Maximum execution time of 30 seconds exceeded error is not related to Laravel but rather your PHP configuration.

Here is how you can fix it. The setting you will need to change is max_execution_time.

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)

You can change the max_execution_time to 300 seconds like max_execution_time = 300

You can find the path of your PHP configuration file in the output of the phpinfo function in the Loaded Configuration File section.

Saturday, August 20, 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 :