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);
}
}
Related
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
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 have a Laravel application working on different urls. example.ch and app.example.net are working will. On the same server like app.example.net i like to run app-stage.example.net.
The application return an error 500 without an error log.
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
var_dump($kernel); // returns an object. Everything ok
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
var_dump($response) //returns error 500
I checked the php version.
I checked the fpm version.
I checked the .env file
I did "sudo chmod -R 777 bootstrap/cache storage"
I restarted the server.
I tried to show the errors.
error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
No success.
What can I do in addition to find the error?
use this package Dotenv
make a file like this
and then use multiple .env for example acceptnace.env . production.env , staging.env
make a file like environment.php in bootstrap directory like this
<?php
$envPath = realpath(dirname(__DIR__));
$env = get_current_user();
if ($env == 'staging') {
$envFile = ".staging.env";
} elseif ($env == "acceptance") {
$envFile = ".acceptance.env";
} elseif ($env == "development") {
$envFile = ".development.env";
} elseif ($env == "production") {
$envFile = ".production.env";
} elseif ($env == "beta") {
$envFile = ".beta.env";
} else {
$envFile = ".local.env";
}
Dotenv\Dotenv::create($envPath, $envFile)->load();
and this will load multiple env for your app
I am working on an app in Laravel which uses Intervention Image library and Imagick to upload and resize images on the fly. Following is my code:
public function saveImage($directory, $imageObject) {
$imageFile = $imageObject->store('app/'.$directory);
$filename = str_replace('app/'.$directory.'/','',$imageFile);
$imageObject = Storage::get($imageFile);
$img = Image::make($imageObject);
$img->resize(null, 40, function ($constraint) {
$constraint->aspectRatio();
});
$imageFile = $img->stream();
Storage::put('app/'.$directory.'/'.$filename, $imageFile->__toString());
// $img->save($imagePath);
return $filename;
}
However the problem occurs on the line Image::make($imageObject). The only error which Heroku returns is 503 Service Unavailable. Please help.
Imagick is a library that needs to be installed on the machine. From heroku docs:
The following built-in extensions have been built “shared” and can be
enabled through composer.json (internal identifier names given in
parentheses):
Add the code from this answer to your composer.json-https://stackoverflow.com/a/35660753/2460352:
...
"require": {
"ext-imagick": "*",
...
}
}
Laravel 5.3
When I download a file (.doc, .docx) from my storage folder it becomes unreadable. If I go to the local folder and open the file however it is valid and readable.
I am using the standard download function, using headers and stuff.. Have a look at my code:
$fileNameGenerate = 'example_filename';
$fileArr = [ 'wierd_filename', 'docx' ];
$cvPath = storage_path('app/example_folder/subfolder/wierd_filename.docx');
$headers = array(
'Content-Type: application/' . $fileArr[1],
);
try {
return response()->download($cvPath, $fileNameGenerate . '.' . $fileArr[1], $headers);
} catch (\Exception $e) {
//Error
return redirect()->back()->with('error', trans('locale.file_does_not_exists'));
}
Does anyone know what is wrong here? Thank you!
Update: I removed headers, it doesn't work with or without them.
Here is how the files render in the 2 different cases:
Try this
public function getDownload()
{
//doc file is stored under storagepath/download/info.docx
$file= pathofstorage. "/download/info.docx";
return response()->download($file);
}
I added:
ob_end_clean();
before:
response -> download
and it worked for me.