PHP Warning: require_once - php

I'M Trying to run a cloned project and set my php evironment but everytime i try to execute php artisan serve commad,it gives me this error... the problem is that im new to laravel...
almando#almando-ThinkPad-Edge-E531:~/Documents/laravelPro/active-ecommerce$ php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Mon Dec 19 00:16:03 2022] PHP Warning: require_once(/home/almando/Documents/laravelPro/active-ecommerce/public/index.php): failed to open stream: No such file or directory in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
[Mon Dec 19 00:16:03 2022] PHP Fatal error: require_once(): Failed opening required '/home/almando/Documents/laravelPro/active-ecommerce/public/index.php' (include_path='.:/usr/share/php') in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
[Mon Dec 19 00:16:03 2022] 127.0.0.1:35764 [200]: /favicon.ico
[Mon Dec 19 00:16:10 2022] PHP Warning: require_once(/home/almando/Documents/laravelPro/active-ecommerce/public/index.php): failed to open stream: No such file or directory in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
[Mon Dec 19 00:16:10 2022] PHP Fatal error: require_once(): Failed opening required '/home/almando/Documents/laravelPro/active-ecommerce/public/index.php' (include_path='.:/usr/share/php') in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
^C
I don't know where to make changes is there someone who help me out on this, i will appreciate it..
below is the server.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Naft Otell <naft#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
below is the index.php
<?php
ini_set('serialize_precision', -1);
/**
* 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);
The question is how would you solve this if it was you?
Thank you

Assuming folder doesn't have the permissions needed, try with this:
chown -R {username}:www-data /home/almando/Documents/laravelPro/active-ecommerce
chmod -R 750 /home/almando/Documents/laravelPro/active-ecommerce
chmod -R 770 /home/almando/Documents/laravelPro/active-ecommerce/storage

Related

php Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\paribibi/public/index.php' (include_path='C:\xampp\php\PEAR')

Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\paribibi/public/index.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\paribibi\server.php on line 21
server.php line 21 - ""require_once DIR.'/public/index.php';""
what should i do now??
it means you public folder is missing index.php
just create a index.php file inside public directory
and paste this code-
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the "down" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
/*
|--------------------------------------------------------------------------
| 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 = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);

Laravel route not found when route exists

When I try to access my laravel site I get this error in the console.
Laravel development server started: <http://127.0.0.1:8000>
[Mon Nov 16 10:39:15 2020] PHP Fatal error: Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389
Stack trace:
#0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true)
#1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home')
#2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...')
#3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/threeacc...', Array)
#4 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\Vi in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389
[Mon Nov 16 10:39:15 2020] PHP Fatal error: Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389
Stack trace:
#0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true)
#1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home')
#2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...')
#3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/threeacc...', Array)
#4 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\Vi in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389
But route home is clearly defined. I even set it at the top of my route file to make sure nothing else was overriding it.
routes/web.php
<?php
// New Home Page for App
Route::get('/', 'Web\HomeController#index')->name('home');
...
with php artisan route:list
+--------+----------------------------------------+--------------------------------------------------------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------------------------------------+--------------------------------------------------------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| | GET|HEAD | .well-known/apple-developer-merchantid-domain-association | | App\Http\Controllers\Web\ApplePayDomainVerificationController | web |
| | GET|HEAD | / | home | App\Http\Controllers\Web\HomeController#index | web |
Update
I've cleared route cache, deleted vendor folder, re-installed PHP but nothing seems to solve the issue.
I've tried it on my work laptop (same setup) and everything works. It seems to be an issue with my current station but I'm not sure what would be causing it. I'm using PHP 7.2 on a mac os 10.14.4. Laravel 5.7
I also thought maybe it was an overall system issue but if I create a new laravel project everything works as expected so it does seem to be a project specific issue.
It was an issue with my apache config. It seems on my latest brew update apache got updated and the config file changed a bit. I had to change
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride all
Require all granted
</Directory>
Route like that is doesn't work except you edit the RouteServiceProvider
There is new version of laravel, please make sure you upgrade your PHP or XAMPP and try to update the composer global laravel and last create a new laravel project.
See Laravel documentation
And this post
https://youtu.be/MfE1tnMG6fE
You can remove name('home'), because error is Route [home] not defined
<?php
// New Home Page for App
Route::get('/', 'Web\HomeController#index');

failed opening required in laravel warning and fatal error

laravel giving error failed opening required thrn (file path)(include_path='C:\xampp\php\PEAR')in (file path)
//my index file code id shown below
//require __DIR__.'public/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'].'public/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__.'/public/bootstrap/app.php';
$app = require_once (realpath($_SERVER["DOCUMENT_ROOT"]).'/public/bootstrap/app.php';
If this is a new installation, you need to run composer install.
If it's an existing installation (vendor folder exists) run composer update.
Step 1:
Run: Composer Install for new Installation.
Run: Composer Update for Existing Installation.
Step 2: Make .env file
Step 3: Run: Php artisan migrate (Make database )
Step 4: Run: Php artisan key:generate

Broadcasting, laravel-echo-server not receiving events

I'm using Laravel in a project and I want to use broadcasting with laravel-echo-server and Redis. I have set up both in a docker container. Output below:
Redis
redis_1 | 1:C 27 Sep 06:24:35.521 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 27 Sep 06:24:35.577 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 27 Sep 06:24:35.577 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | 1:M 27 Sep 06:24:35.635 * Running mode=standalone, port=6379.
redis_1 | 1:M 27 Sep 06:24:35.635 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 27 Sep 06:24:35.635 # Server initialized
redis_1 | 1:M 27 Sep 06:24:35.635 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1 | 1:M 27 Sep 06:24:35.636 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 27 Sep 06:24:35.715 * DB loaded from disk: 0.079 seconds
redis_1 | 1:M 27 Sep 06:24:35.715 * Ready to accept connections
A few warnings but nothing breaking.
laravel-echo-server
laravel-echo-server_1 | L A R A V E L E C H O S E R V E R
laravel-echo-server_1 |
laravel-echo-server_1 | version 1.3.1
laravel-echo-server_1 |
laravel-echo-server_1 | ⚠ Starting server in DEV mode...
laravel-echo-server_1 |
laravel-echo-server_1 | ✔ Running at localhost on port 6001
laravel-echo-server_1 | ✔ Channels are ready.
laravel-echo-server_1 | ✔ Listening for http events...
laravel-echo-server_1 | ✔ Listening for redis events...
laravel-echo-server_1 |
laravel-echo-server_1 | Server ready!
laravel-echo-server_1 |
laravel-echo-server_1 | [6:29:38 AM] - dG0sLqG9Aa9oVVePAAAA joined channel: office-dashboard
The client seems to join the channel without any problems.
However, if I kick of an event laravel-echo-server doesn't receive the event.
I did a bit of research and found something about a queue worker. So I decided to run that (php artisan queue:work) and see if that did anything. According to the docs it should run only the first task in the queue and then exit (as opposed to queue:listen). And sure enough it began processing the event I kicked of earlier. But it didn't stop and kept going until I killed it:
[2017-09-27 08:33:51] Processing: App\Events\CompanyUpdated
[2017-09-27 08:33:51] Processing: App\Events\CompanyUpdated
[2017-09-27 08:33:51] Processing: App\Events\CompanyUpdated
[2017-09-27 08:33:51] Processing: App\Events\CompanyUpdated
etc..
The following output showed in the redis container:
redis_1 | 1:M 27 Sep 06:39:01.562 * 10000 changes in 60
seconds. Saving...
redis_1 | 1:M 27 Sep 06:39:01.562 * Background saving started by pid 19
redis_1 | 19:C 27 Sep 06:39:01.662 * DB saved on disk
redis_1 | 19:C 27 Sep 06:39:01.663 * RDB: 2 MB of memory used by copy-on-write
redis_1 | 1:M 27 Sep 06:39:01.762 * Background saving terminated with success
Now I either did so many api calls that the queue is so massive, or something is going wrong. Additionally, laravel-echo-server didn't show any output after the jobs were 'processed'.
I have created a hook in my Model which kicks of the event:
public function __construct(array $attributes = []) {
parent::__construct($attributes);
parent::created(function( $model ){
//event(new CompanyCreated($model));
});
parent::updated(function( $model ){
event(new CompanyUpdated($model));
});
parent::deleted(function( $model ){
event(new CompanyDeleted($model));
});
}
Then this is the event it kicks off:
class CompanyUpdated implements ShouldBroadcast {
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* #return void
*/
public function __construct(Company $company) {
$this->company = $company;
}
/**
* Get the channels the event should broadcast on.
*
* #return Channel|array
*/
public function broadcastOn() {
return new Channel('office-dashboard');
}
}
And finally, this is the code on the front-end that's listening for the event:
window.Echo.channel('office-dashboard')
.listen('CompanyUpdated', (e) => {
console.log(e.company.name);
});
.env file:
BROADCAST_DRIVER=redis
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=redis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
Why isn't the event passed to laravel-echo-server? Anything I'm missing or forgetting?
Started working out of the blue.
For me, #jesuisgenial's comment pointed me in the right direction.
You can easily identify if it's not subscribing by checking the Websockets tab under the Networking tab in Chrome developer tools
Without 1 second delay (no subscribe event):
Echo.private(`users.${context.getters.getUserId}`)
.listen('.conversations.new_message', function(data) {
console.log(data.message);
})
With 1 second delay (subscribe event present):
setTimeout(() => {
Echo.private(`users.${context.getters.getUserId}`)
.listen('.conversations.new_message', function(data) {
console.log(data.message);
})
}, 1000)

unable to live site in server laravel5

iam getting an error after uploaded project to server. when i visited to link somedomain.com/DEMO i got following error. What actually is this error? how can i solve it please help me.
Warning: require(/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php): failed to open stream: No such file or directory in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
Fatal error: require(): Failed opening required '/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
my index.php is like this:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #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__.'/project/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__.'/project/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');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
project is main folder . Inside projetc i have app,vendor,bootstrap,config,database,resources etc
Here are some of the best practices while launching a Laravel app on server.
Try them out. Might solve your issues. These steps have solved almost every problem that I have faced till now while launching a site on server.
1.Enable Mod_Rewrite
a2enmod rewrite
2.Install php 5.6
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
While returning views, always use Foldername.viewname instead of Foldername\viewname
use public_path() while including files
chmod -R 777 "Storage folder path"
This file doesn't exist:
/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php

Categories