Error thrown when running existing Laravel project on local server - laravel

UPDATE: I think updating to a newer php version (by updating homebrew) causes this problem... Could/should I update the Laravel version of the project I'm working on? Or install a lower php version? I have no experience with that...
I'm working on a Laravel project for quite some time no. All of a sudden an exception is thrown when starting the local server.
The ErrorException is: trim(): Passing null to parameter #1 ($string) of type string is deprecated
It points to a few lines in the routes/web.php file.
ErrorException
trim(): Passing null to parameter #1 ($string) of type string is deprecated
at vendor/laravel/framework/src/Illuminate/Routing/RouteGroup.php:65
61▕ {
62▕ $old = $old['prefix'] ?? null;
63▕
64▕ if ($prependExistingPrefix) {
➜ 65▕ return isset($new['prefix']) ? trim($old, '/').'/'.trim($new['prefix'], '/') : $old;
66▕ } else {
67▕ return isset($new['prefix']) ? trim($new['prefix'], '/').'/'.trim($old, '/') : $old;
68▕ }
69▕ }
+6 vendor frames
7 routes/web.php:90
Illuminate\Routing\RouteRegistrar::group(Object(Closure))
+3 vendor frames
11 routes/web.php:91
Illuminate\Routing\RouteRegistrar::group(Object(Closure))
This are the lines in the web.php file
Route::middleware(['auth.isAdminPers'])->group(function () {
Route::get('/admin/admin',function () {
return view('admin.admin');
});
Route::get('admin/dienstverplaatsingen',[AdminDienstverplaatsingController::class,'index'])->name('admin.dienstverplaatsingen');
Route::get('/admin/experiment',[gebruikerController::class, 'experiment']);
Route::get('/admin/export',[AdminDienstverplaatsingController::class,'export']);
Route::get('/admin/fietsritten', [AdminFietsritten::class,'index'])->name('admin.fietsritten');
Route::get('/admin/fietsrittengrouped', [fietsrittengrouped::class, 'index'])->name('admin.fietsrittengrouped');
Route::get('/admin/maaltijden',[AdminMaaltijden::class,'index'])->name('admin.maaltijden');
Route::get('/admin/maaltijdengrouped',[maaltijdengrouped::class,'index'])->name('admin.maaltijdengrouped');
Route::prefix('admin')->name('admin.')->group(function(){
Route::get('/users/export', [UserController::class,'export'])->name('users.export');
Route::resource('/users', UserController::class);
Route::get('/appsettings', function(){
return view('admin.settings');
})->name('appsettings');
});
});

I just had this problem earlier. The way I have solved it was by running php artisan route:cache before composer install. Keep in mind that I am using PHP 7.4 with Laravel 8.

Related

The provided cwd "C:\laravel projects\eccomer/../public_html" does not exist

when i try to run serve in laravel i got this error
Symfony\Component\Process\Exception\RuntimeException
The provided cwd "C:\laravel projects\eccomer/../public_html" does
not exist.
at C:\laravel
projects\eccomer\vendor\symfony\process\Process.php:344
340▕ }
341▕ }
342▕
343▕ if (!is_dir($this->cwd)) { ➜ 344▕ throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.',
$this->cwd));
345▕ }
346▕
347▕ $this->process = #proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs,
$this->options);
348▕
1 C:\laravel
projects\eccomer\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:128
Symfony\Component\Process\Process::start(Object(Closure))
2 C:\laravel
projects\eccomer\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:68
Illuminate\Foundation\Console\ServeCommand::startProcess()
i try anything but does not work
i fixed error like this :
in app/Providers/AppServiceProvider.php file in boot funcation i copy this code:
public function boot()
{
Paginator::useBootstrap();
}
and my problem fixed

Laravel and php wrapper for youtube-dl norkunas / youtube-dl-php

I'm using Laravel Version 6.14.0 and I wanted to use the following Youtube-dl wrapper for PHP from https://github.com/norkunas/youtube-dl-php in Laravel.
I used the command composer require norkunas/youtube-dl-php to install it and I got the following output :
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing symfony/options-resolver (v4.4.4): Downloading (100%)
- Installing norkunas/youtube-dl-php (v1.4.0): Downloading (100%)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
This is what my Controller looks like
<?php
namespace App\Http\Controllers;
use App\YtScreen;
use Illuminate\Http\Request;
use YoutubeDl\YoutubeDl;
use YoutubeDl\Exception\CopyrightException;
use YoutubeDl\Exception\NotFoundException;
use YoutubeDl\Exception\PrivateVideoException;
class YtScreenController extends Controller
{
public function frontpage()
{
$dl = new YoutubeDl([
'continue' => true, // force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.
'format' => 'bestvideo',
]);
// For more options go to https://github.com/rg3/youtube-dl#user-content-options
$dl->setDownloadPath('/home/user/downloads');
// Enable debugging
$dl->debug(function ($type, $buffer) {
if (\Symfony\Component\Process\Process::ERR === $type) {
echo 'ERR > ' . $buffer;
} else {
echo 'OUT > ' . $buffer;
}
});
try {
$video = $dl->download('https://www.youtube.com/watch?v=oDAw7vW7H0c');
echo $video->getTitle(); // Will return Phonebloks
// $video->getFile(); // \SplFileInfo instance of downloaded file
} catch (NotFoundException $e) {
// Video not found
} catch (PrivateVideoException $e) {
// Video is private
} catch (CopyrightException $e) {
// The YouTube account associated with this video has been terminated due to multiple third-party notifications of copyright infringement
} catch (\Exception $e) {
// Failed to download
}
return view("frontpage");
}
}
The problem is that the newly installed php wrapper doesn't work at all. I don't even get an error message. No video gets downloaded, no error message is shown ... nothing happens. The controller itself is fine , I tested it with a different function.
I assume I didn't include the files correctly since I don't even get an error message. Has anyone made a similiar expirience and knows how to get this php wrapper for youtube-dl to work in Laravel? Or maybe has an alternative idea for a different youtube-dl php wrapper.

Laravel php artisan produces error

I have integrated and working in a Laravel 5.4 project. I was actually configure this correctly and php artisan command was working perfectly before.But in between the development time(I have implemented the schedule task using laravel and not sure after that issue appear) it produces m error on php artisan commands. Can anybody help me on this.
The following is the error log for the command for any artisan command
PHP Fatal error: Uncaught
Symfony\Component\Debug\Exception\FatalThrowableError: Type error:
Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct()
must be an instance of Illuminate\Http\Request, null given, called in
/var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php
on line 60 in
/var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:103
Stack trace:
#0 /var/www/html/projrct/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(60):
Illuminate\Routing\UrlGenerator->__construct(Object(Illuminate\Routing\RouteCollection),
NULL)
#1 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(290):
Illuminate\Routing\RoutingServiceProvider->Illuminate\Routing{closure}(Object(Illuminate\Foundation\Application))
#2 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(746):
Illuminate\Container\Container->Illuminate\Container{closur in
/var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php
on line 103
Please make sure that you are not using any url() or asset() or other helpers functions inside your configuration files
I my case url() helper function in my filesystem.php is causing the issue. I removed it and every thing works fine.
Another alternative solution to commenting out the url() and asset() calls could be to check the environment at run time:
return [
'URL' => app()->runningInConsole() ? '' : url(''),
...
];
If Really Need The Function To Be Inside Your Config, You Could use PHP_SAPI
To Check Weather The App Is Running HTTP or CLI,
'redirect' => PHP_SAPI === 'cli' ? false : url('synchronise')
I figured out the problem, when you are running any artisan command you should avoid using helper functions in any of your config files. Just comment those and try to run artisan command after running that uncomment your config files.
//in config/'any_file.php'
return [
'name' => 'Larvel',
'url' => url('/')
];
//just change and uncomment url() helper
return [
'name' => 'Larvel',
//'url' => url('/')
];
Well I got stuck at same issue while I was using asset in config file (adminlte.php) of Admin LTE.
Please comment your asset, url while using artisan command in config files like this
[
'type' => 'js',
'asset' => false,
// 'location' => asset('js/waitme/waitMe.min.js'),
],

Moved Laravel dir to root of server now composer update fails

I wanted the Laravel 4.1 package to be at the root of a particular web server so I took it out of it's "laravel" dir and moved it.
Used to be in: C:\www\mysite.dev\laravel
Now it is in: C:\www\mysite.dev
When I run composer update it chokes producing the error:
{"error":{"type":"ErrorException","message":"mkdir(): No such file or directory","file":"C:\\www\\mysite.dev\\vendor\\laravel\\framework\\src\\Illuminate\\Filesystem\\Filesystem.php","line":302}}
How can I configure composer.json to compensate for this change?
It seems like problem with permissions.
Line 302 of Filesystem.php is the following (in bold):
public function makeDirectory($path, $mode = 0777, $recursive = false, $force = false)
{
if ($force)
{
return #mkdir($path, $mode, $recursive);
}
else
{
302 return mkdir($path, $mode, $recursive);
}
}

Phonegap 3 - LocalFileSystem not defined

I used this code in phonegap 2.6.0 and it worked, now I upgraded to phonegap 3.0.0 and xcode 5 and I get this error:
onDeviceReady: =>
try
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, failFS)
catch e
alert(e)
**ReferenceError: LocalFileSystem is not defined**
I get the same error in Chrome, and that I guess is normal?
The documentation is still the same from 2.6 to 3, so Im not sure what happend!
I solved the problem adding cordova.js file to platforms/ios/www/
You should add File plugin to your app using:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
You may want to check this:
http://docs.phonegap.com/en/edge/cordova_file_file.md.html#File
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
function gotFS(fileSystem) {
console.log("got filesystem");
console.log(fileSystem.root.fullPath);
}
function fail() {
console.log("failed to get filesystem");
}

Resources