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
Related
I'm trying to run some services on a ubuntu server using process() (from Symfony\Component\Process\Process)
$process = new Process(['systemctl', '--user', 'start', $serviceName]);
try {
$process->mustRun();
}
catch (ProcessFailedException $ex) {
Log::alert($ex->getMessage());
}
but I'm getting the following error:
The command "'systemctl' '--user' 'start' 'some_service_name.service'" failed.
Exit Code: 1(General error)
Working directory: /
Output:
Error Output:
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>#.host --user to connect to bus of other user)
Any help would be much appreciated!
I figured it out, for anyone facing the same problem the argument "--machine=username#.host" was missing.
so the end result should be something like this:
$process = new Process(['systemctl', '--machine=USER_HERE#.host', '--user', 'start', $serviceName]);
try {
$process->mustRun();
}
catch (ProcessFailedException $ex) {
Log::alert($ex->getMessage());
}
(replace the USER_HERE with your user)
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.
I'm trying to test all the routes on my api but only the first request gets 200, all the other following requests get 404. But if I run any test individually using (phpunit --filter test_something) it works.
<?php
class ProgramTest extends TestCase {
/** #test */
public function it_returns_index() {
$this->get('api/v1/test')
->assertReturnOk(['limit' => 10]);
}
/** #test */
public function it_returns_show() {
$this->get('api/v1/test/12')
->seeJson(['id' => 12]);
}
}
getting error as
PHPUnit 4.8.23 by Sebastian Bergmann and contributors.
.F
Time: 2.33 seconds, Memory: 20.25Mb
There was 1 failure:
1) ProgramTest::it_returns_show
Invalid JSON was returned from the route. Perhaps an exception was thrown?
You need to fix the problem in Routes.php I think. I have seen a similar question that has been answered in the below link. Hope this would solve you. The Route modification that was done is as per the below link
$phpunit = simplexml_load_file('phpunit.xml');
foreach (File::allFiles(__DIR__ . '/Routes') as $partial) {
if ($phpunit->php->xpath('env[#name="APP_ENV"]')[0]['value'] == 'testing') {
require $partial->getPathname();
} else {
require_once $partial->getPathname();
}
}
https://laracasts.com/discuss/channels/testing/test-api-404-on-multiple-requests
I am getting this error in my log file when I run codeception test case. How to fix this?
Code:
public function testUpdatePhone(FunctionalTester $I)
{
$I->wantTo('Test update phone');
$I->sendPUT('/admin/phone/100', [
'label' => 'My new label'
]);
$I->see('Phone Number updated successfully.');
}
Command:
./vendor/bin/codecept run
tests/functional/AdminPhoneTestCest.php:testUpdatePhone
Error in Log file:
[2015-06-06 05:34:02] local.ERROR: exception
'Illuminate\Session\TokenMismatchException' in
/var/www/xxxx/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:46
Thanks in advance :)
This issue has been fixed by adding middleware method as follows
public function handle($request, Closure $next)
{
if ($request->header('user-agent') == 'Symfony2 BrowserKit') {
return $next($request);
}
throw new TokenMismatchException;
}
Reference: https://laracasts.com/discuss/channels/general-discussion/latest-v5-laravelframework-csrfmiddleware-changes-broke-codeception-functional-tests
If you're using phantomjs, you will need to ensure you have clear_cookies: true in your settings as the normal restart: true doesn't seem to be supported for phantomjs, so it uses the same token which is invalid in subsequent tests.
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);
}
}