i have a problem after trying to deploy my Laravel 9 application on AWS, my environment is healthy but still get this error when trying access to the site :
[ unexpected token ")" in public/index.php:51]
Error image
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Kernel::class);
//this is the error line 51
$response = $kernel->handle($request = Request::capture())->send();
$kernel->terminate($request, $response);
Using PHP 8.1.6
Related
I started the project through laravel sail and I can't see the
view's index on localhost, when I enter the link I get the error:
target class [] does not exist.
and below that error message shows the following code, which corresponds to the index.php file:
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
| Check If The Application Is Under Maintenance
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
*/
if (file_exists($maintenance =
__DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
/*
| Register The Auto Loader
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
*/
require __DIR__.'/../vendor/autoload.php';
/*
| Run The Application
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);
The content that I put in the view index.blade.php should be
displayed, the route was declared, the controller exists and the
above error appears
I want to deploy my laravel application on a shared webhost, I have follow this tutorial https://www.youtube.com/watch?v=6g8G3YQtQt4 and its works perfectly, only if I put the public folder in public_html, but I want to put in another folder in public_html, (to be more exactly, in: public_html/myapp, but I get this error
[15-Apr-2022 15:19:32 UTC] PHP Warning: require(/home/killestone/public_html/myapp/../web/vendor/autoload.php): failed to open stream: No such file or directory in /home/killestone/public_html/myapp/index.php on line 24
[15-Apr-2022 15:19:32 UTC] PHP Fatal error: require(): Failed opening required '/home/killestone/public_html/myapp/../web/vendor/autoload.php' (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home/killestone/public_html/myapp/index.php on line 24
this is my index.php inside public_html/myapp
The rest of my laravel application is on /home/killestone/web/
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| 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__.'/../web/vendor/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__.'/../web/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(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
Because your public directory lives inside sub-folder inside the public_html
so you need to add an extra ../ because your public app lives in
public_html/myapp
so the first ../ will point to the public_html dir and the second ../ will point you to the home directory
like this
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| 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__.'/../../web/vendor/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__.'/../../web/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(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
My PHP version is 7.2
i have uploaded my my laravel 5.7.9 in to public_html folder and then i moved files of public folder into public_html folder. and i edited my index.php file.
here is the code of my index.php file
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| 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__.'/vendor/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(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
?>
But still i am getting this error.anybody please help me
This page isn’t working
desktim.contents.management is currently unable to handle this request.
HTTP ERROR 500
Revert your index.php file to its original state and use following method
As Burak Erdem mentioned, another option (and more preferable) is to put this in the \App\Providers\AppServiceProvider register() method.
/**
* Register any application services.
*
* #return void
*/
public function register()
{
// ...
$this->app->bind('path.public', function() {
return base_path('public_html');
});
}
Change this code in your index.php file
$app = require_once __DIR__.'/../bootstrap/app.php';
require __DIR__.'/../vendor/autoload.php';
I am having trouble understanding the dynamic structure of PHP. I don't know PHP very well but I do know how to code JavaScript, HTML, and CSS.
A website that I help manage has an environment meant for Macs. I am not a Mac user in the least and would know how to get this local instance of the website up and running.
Tried using Vagrant, got it and not many tutorials tell me how it could be done, so then I used PhpStorm to run the server then I keep getting this error on line 21 of this file.
I am trying to find where I point the system directory and find the autoload.php file which I do have. But being originally created on a Mac makes it very difficult.
Here is the error:
Warning: require(D:\Vagrant
project\compasshb.com\public/boostrap/autoload.php): failed to open stream:
No such file or directory in D:\Vagrant
project\compasshb.com\public\index.php on line 22
Fatal error: require(): Failed opening required 'D:\Vagrant
project\compasshb.com\public/boostrap/autoload.php'
(include_path='.;C:\php\pear') in D:\Vagrant
project\compasshb.com\public\index.php on line 22
Makes no sense to me.
Here is line 22 in index.php:
<?php
/**
* Laravel - A PHP Framework For Web Artisans.
*
* #author Taylor Otwell <taylorotwell#gmail.com>
*/
/*
|--------------------------------------------------------------------------
| 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 nice to relax.
|
*/
require __DIR__.'/boostrap/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(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
i already upload files in the public folder to public_html, and others to laravel.
i changed index.php too.
but i get nothing ....
[
I get this...
Some one can help me?
Thanks
EDIT:
This is my index file, i think thats is good
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
/*
|--------------------------------------------------------------------------
| 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 nice to relax.
|
*/
require __DIR__.'/../laravel/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__.'/../laravel/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(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
EDIT:
Now i have this locally in XAMPP
The question is quite old however others may find this answer useful. Basically what you have to do is to configure the App to work properly in the new environment.
Go to 000webhost cPanel > Settings > General > Reset website. You must make sure no other content is present in your site to prevent interference.
Archive your entire Laravel Project in ZIP format.
Upload the archive to 000webhost site to /public_html using File Manager.
Move all files/folders which are on the same level with package.json to /
Delete /public_html. You won't need it anymore.
Rename /public to /public_html
Go to /app/Providers/AppServiceProvider.php at register() method and append the following code inside it:
$this -> app -> bind('path.public', function()
{
return base_path('public_html');
});
Open /.env. Copy APP_KEY value without base64:
Go to /config/app.php, find 'key' and replace the line with the following code:
'key' => env('APP_KEY', base64_decode('%YOUR_COPIED_APPKEY%'));
If you have your project connected to a database, update the database credentials from /config/database.php. Lookup for mysql vector and update the database, username, password properly.
...And this should do the trick. If you have further questions, a tutorial has been written about the entire procedure here: https://www.000webhost.com/forum/t/deploy-laravel-project-into-000webhost-site/127323/
Hope this helps :)
WRITE YOUR index.php
$app->bind('path.public', function() {
return __DIR__ ;
});