I installed a Laravel project, as I am trying to learn the framework. I am now trying to work on a different machine and I can't set it up.
I get these errors:
blog git:(development) php artisan migrate:install
[ErrorException]
include(/home/ioto/www/my-bitbucket/blog/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php): failed to open stream: No such file or directory
although when I try to check if the file actually exists I can see it but I can't access it:
➜ blog git:(development) cd vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver
➜ Driver git:(development) ls -lisa
total 112
[...]
26740122787838334 4 -rw-rw-rw- 0 777 ioto 3695 sep 10 15:00 PDOConnection.php
[...]
➜ Driver git:(development) cat PDOConnection.php
cat: PDOConnection.php: No such file or directory
I am using "bash on ubuntu on windows"
I get the same errors if I try different things like other artisan commands, if I try to serve the application and so on. I tried a new composer update after deleting the vendor folder. Set chmod to 777, but I'm out of ideas...
Any suggestions on what can I try to debug this ?
Related
I'm trying to extract a zip archive in a docker container app running Laravel 9 on PHP 8.1.7, and i'm facing a weird error.
So if a try this code in a controller
$zip = new ZipArchive();
$result = $zip->open("/var/www/html/public/my_archive.zip");
if ($result === TRUE) {
$zip->extractTo("/var/www/html/public/my_folder");
}
$zip->close();
the files in archive are correctly extracted, but return this error:
ErrorException
ZipArchive::extractTo(/var/www/html/public/my_folder/my_file.xml): Operation failed: Operation not permitted
If I run the same code in php artisan tinker it works.
Anyone have some idea to fix this problem?
It don't seem a permissions related problem, the folder is created with 777 permission and the files are copied correctly.
EDIT
root#5899a5badc45:/var/www/html/public/my_folder# ls -lhart *
-rwxrwxrwx 1 1000 1000 1.3K Oct 25 12:24 phpunit.xml
Thanks
I'm using Symfony 5.0.7
My live deploy ansible after-symlink-shared.yaml file:
---
- name: Set up infrastructure-related parameters
template:
src: '{{ playbook_dir }}/templates/.env_live.dist'
dest: '{{ ansistrano_release_path.stdout }}/.env'
- name: Install Composer dependencies
composer:
command: install
arguments: --classmap-authoritative
no_dev: no
optimize_autoloader: yes
working_dir: '{{ ansistrano_release_path.stdout }}'
- name: Clear the cache
command: 'php {{ release_console_path }} cache:clear --no-warmup --env=prod'
- name: Warm up the cache
command: 'php {{ release_console_path }} cache:warmup --env=prod'
- name: Create DB if not exists
command: 'php {{ release_console_path }} doctrine:database:create --if-not-exists --env=prod'
register: create_db_output
changed_when: create_db_output.stdout is not search('already exists. Skipped')
- name: Run migrations
command: 'php {{ release_console_path }} doctrine:migrations:migrate --no-interaction --env=prod'
register: run_migrations_output
changed_when: run_migrations_output.stdout is not search('No migrations to execute')
- name: Install bundle assets
command: 'php {{ release_console_path }} assets:install --symlink --env=prod {{ ansistrano_release_path.stdout }}/public'
- name: Copy build directory
command: 'cp -a {{ ansistrano_release_path.stdout }}/public/build /var/www/project/public'
tags:
- deploy
The deployment works perfectly, however every time I deploy to the server, my production environment hits a 500 error.
I take a look at my prod.log file to understand what is causing the error and I get the following:
[2020-05-09 21:40:59] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler)." at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 43 {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] php.CRITICAL: Uncaught Exception: Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler)." at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 43 {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] php.CRITICAL: Uncaught Exception: Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"}
This looks like a permissions issue because every time I deploy, this error comes up. Is is possible I can do something from the NGINX perspective to ensure this functions properly? Or is this an ansible solution? I'm trying to avoid manually fixing these errors with each deployment.
The user running the deployment seems to be different than the one that runs php, that's why the user doesn't have permissions to the cache directory after cache:warmup is run.
You have several options:
Change the user the app runs under:
Since you say you are using nginx I guess you are running php-fpm. You can change the user and group parameters in your php-fpm.conf to the one running the deployment. If you are running multiple applications, create a new pool. (Here's slightly outdated guide to fpm and pools to get you going, and the FPM reference).
Adjust primary groups and umask or acls so both users have access.
Run the cache tasks as the php user using become.
Fix permissions as part of the deploy process by running an ansible task. You can use the file module for this. You can either use open permissions or use become.
Keep in mind that using become (the last two options) requires changing the sudoers file so the deploy user can act as the php user.
If you have an uploads directory under public that needs write access by the php process, you need to fix those permissions too.
I figured out the issue.
It was purely a permissions issue that I had to firstly go to the highest level folder of where the var prod folder was and updated the permissions using chown then updated the permissions for all folder below recursively using chmod to ensure everything else moving forward would be written just as the parent was.
Issue happens probably because ansible runs on root user, but PHP server didn't
Try to add the last step for change ownership of directory in the playbook
- name: Fix user rights
command: 'chown -R www-data: /var/www/project/public'
tags:
- deploy
in my example ownership grants to user www-data (default), but in your case it can be different.
For check right user, use command
cd /var/www/project && ls -la
here is my shell snip
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/app
$ bin/cake serve
Exception: Shell class for "Serve" could not be found. in [D:\xampp1\htdocs\app\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/app
$ cd ../pocketpa-git-clone000000/
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/pocketpa-git-clone000000 (master)
$ bin/cake serve
Exception: Shell class for "Serve" could not be found. in [D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]
Warning Error: file_put_contents(D:\xampp1\htdocs\pocketpa-git-clone000000\logs\cli-error.log): failed to open stream: No such file or directory in [D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Log\Engine\FileLog.php, line 133]
PHP Warning: file_put_contents(D:\xampp1\htdocs\pocketpa-git-clone000000\logs\cli-error.log): failed to open stream: No such file or directory in D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Log\Engine\FileLog.php on line 133
last night i shut down my pc and in morning when i restart i am facing this issue
cakephp version 3.4.14
php 5.6.36
and having this problem when wants to start project
Sorry my bad i was messed up with diffferent projects i was working on Laravel Projects and using frequently
php artisan serve
This command will start a development server at http://localhost:8000:
when i come back to CakePhp Project i was messed up and trying
bin\cake serve
command to start local server for cakephp environment http://localhost:8765/
thats make me so much trouble
But the orignal command to run CakePhp Sever on LocalHost is
bin\cake server
here you can get more details https://book.cakephp.org/3.0/en/installation.html#development-server
I have used Tinker before but suddenly it stopped working, no matter what project, what version, new or existing. I am on a macbook pro 2013, mac os Sierra, iterm2 with zsh. I have researched all over and not found anything of relevance with exception of one reference in stack overflow to https://github.com/bobthecow/psysh/issues/382 which doesn't show resolution, is not laravel specific but seems to be involving the psy shell (all other artisan commands are fine):
vagrant#homestead:~/Code/application$ php artisan tinker
[ErrorException]
Writing to /home/vagrant/.config/psysh is not allowed.
Is the error I am shown. Vagrant is set up through virtual box running homestead-7.
When I ssh into vagrant and ls -la I see the .config folder but cannot access it nor can I mkdir mvdir due to access denied errors. (Which if I am learning from the stack trace below is where the error is being triggered? Top of the trace where the touchfilemkdir is at?) The folder itself is owned by vagrant. I can make out where the error is triggering but I don't know why it could possibly be triggering regardless of what version of laravel I use, whether it is an existing project or a new download.
Within the laravel projects themselves, I have
"laravel/tinker": "~1.0",
in the composer.json and
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class
is located in app/cofig/app.php.
I did run a verbose stack trace though I'm not exactly sure just what it is pointing to as to what has broken or why.
Exception trace:
() at
/home/vagrant/Code/lightpointLP/vendor/psy/psysh/src/Psy/ConfigPaths.php:213
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
trigger_error() at /home/vagrant/Code/lightpointLP/vendor/psy/psysh/src/Psy/ConfigPaths.php:213
Psy\ConfigPaths::touchFileWithMkdir() at /home/vagrant/Code/lightpointLP/vendor/psy/psysh/src/Psy/Configuration.php:361
Psy\Configuration->setHistoryFile() at /home/vagrant/Code/lightpointLP/vendor/psy/psysh/src/Psy/Configuration.php:409
Psy\Configuration->getHistoryFile() at /home/vagrant/Code/lightpointLP/vendor/psy/psysh/src/Psy/Configuration.php:546
Psy\Configuration->getReadline() at /home/vagrant/Code/lightpointLP/vendor/psy/psysh/src/Psy/Shell.php:82
Psy\Shell->__construct() at /home/vagrant/Code/lightpointLP/vendor/laravel/tinker/src/Console/TinkerCommand.php:53
Laravel\Tinker\Console\TinkerCommand->handle() at n/a:n/a
call_user_func_array() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
Illuminate\Container\BoundMethod::callBoundMethod() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
Illuminate\Container\BoundMethod::call() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Container/Container.php:539
Illuminate\Container\Container->call() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Console/Command.php:182
Illuminate\Console\Command->execute() at /home/vagrant/Code/lightpointLP/vendor/symfony/console/Command/Command.php:264
Symfony\Component\Console\Command\Command->run() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Console/Command.php:167
Illuminate\Console\Command->run() at /home/vagrant/Code/lightpointLP/vendor/symfony/console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at /home/vagrant/Code/lightpointLP/vendor/symfony/console/Application.php:228
Symfony\Component\Console\Application->doRun() at /home/vagrant/Code/lightpointLP/vendor/symfony/console/Application.php:130
Symfony\Component\Console\Application->run() at /home/vagrant/Code/lightpointLP/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
Illuminate\Foundation\Console\Kernel->handle() at /home/vagrant/Code/lightpointLP/artisan:35
If any other information may be required I'll be glad to provide it, I'm truly at a loss as to what has happened or how to fix it.
Thank you
UPDATE AUGUST 31
So I have found that when I am in vagrant#homestead and I sudo su when I then am in root#homestead:/home/vagrant# and I enter .config there is a configstore directory and a psysh directory but it was owned by root. I changed the owner to vagrant, exited, reloaded vagrant and the same error.
drwx------ 2 root root 4096 May 4 00:55 configstore
drwxr-xr-x 2 vagrant vagrant 4096 Aug 31 23:37 psysh
So then I tried sudo -i and got root#homestead but found that the contents of .config were different. This time it has .composer directory and no psysh existing. So I added the psysh directory with vagrant as owner
drwxr-xr-x 2 root root 4096 Feb 26 2017 composer
drwxr-xr-x 2 vagrant vagrant 4096 Aug 31 23:59 psysh
but this still also does not work. I also exited, reloaded vagrant, I config:cleared on both but I get the same unable to write error.
I am so at a loss, any insight would help, please. Thanks!
Answer on https://laracasts.com/discuss/channels/servers/tinker-doset-work-in-shared-hosting?page=1&replyId=604794
#You need to create a config file for PsySH with runtimeDir variable.
# Just create a file ~/.config/psysh/config.php with:
<?php
return [
'runtimeDir' => '~/tmp'
];
Looks like it's an issue with PsySH http://psysh.org/.
I can't answer the question but it looks like this guy had the same issue. It may be worthwhile to get ahold of him and asked how he fixed it.
https://github.com/bobthecow/psysh/issues/382
Have you tried running composer update? Good luck.
I had this exact same issue and it persisted for days. I fixed it by running composer dump-autoload from the project directory. I previously tried the command but it didn't work because I was trying it without internet access, make sure you are connected to the internet when you run the command. Goodluck!
I tried composer update, dump-autoload but nothing worked. Simply changed the permission on the ~./config folder and it worked. You can set 755 or higher (I am not talking about the production environment here).
I've executed the next commаnd on my terminаl:
sudo chmod -R 775 ~/.config
I have able to successfully deploy a php application using git in elastic beanstalk, but the configuration files doesnot work. I created a .ebextensions folder on my root application folder and created a config file with the following command:
container_commands:
00_make_assets:
command: "sudo mkdir /var/app/current/assets"
I get the following error message on the dashboard
Command failed on instance. Return code: 1 Output: [CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 00_make_assets failed.
All I want to do is create a folder and give 777 permission to it.
The output in the log file (/var/log/eb-commandprocessor.log) shows:
[2014-10-17T11:01:43.487Z] ERROR [2341] : Command CMD-AppDeploy failed!
[2014-10-17T11:01:43.488Z] INFO [2341] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","truncated":"false","results":[{"status":"FAILURE","msg":"[CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 00_make_assets failed","returncode":1,"events":[]}]}
Has anyone been in this situation? How can this issue be solved? Any help will be much appreciated.