I'm working on a script to start the laravel project from a github repo.
start cmd /c "mysqld" mysqld --log_syslog=0 --console
cd ./html/BackendAPI/
composer install --no-interaction
php artisan key:generate --no-interaction
php artisan migrate:fresh --seed --no-interaction
But the console closes after the composer install.
Any idea how to do it?
Use call to run composer install command
Like below
start cmd /c "mysqld" mysqld --log_syslog=0 --console
cd ./html/BackendAPI/
call composer install --no-interaction
php artisan key:generate --no-interaction
php artisan migrate:fresh --seed --no-interaction
Related
I have the following bash script for Laravel gitlab CI deployment
docker-compose -p project exec php8 bash -c '
composer install --working-dir="dashboard" &&
wp acorn config:clear --allow-root &&
wp acorn view:clear --allow-root &&
wp acorn optimize:clear --allow-root &&
wp rewrite flush --allow-root &&
php dashboard/artisan migrate &&
php dashboard/artisan optimize:clear &&
php vendor/phpunit/phpunit/phpunit --testsuite=Feature'
but the test are not executed because of the following error Could not open input file: vendor/phpunit/phpunit/phpunit if I ls the directory everything seems to be on the right place. How to debug this issue
I have an app running with docker and laravel but there are some instructions that apparently are executed but not functioning.
These instructions are php artisan clear:cache and php artisan optimize.
Sometimes I need to get into the container and run these instructions in order to have my changes reflected in the browsers. Apart from the failures that kubernetes detects due to the unreflected changes
FROM php:7.2.0-fpm as php
RUN apt-get update && apt-get install -y openssl openssh-client \
rsync sshpass zip unzip git vim libmcrypt-dev mysql-client \
libssh2-1-dev libmagickwand-dev \n
gnupg2 --no-install-recommends zlib1g-dev sass \
&& pecl install mcrypt-1.0.1 \
&& docker-php-ext-enable mcrypt \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install gd \
&& docker-php-ext-install zip \
&& pecl install ssh2-1.0 \
&& docker-php-ext-enable ssh2
RUN curl --silent --location https://deb.nodesource.com/setup_11.x | bash -
RUN apt-get install -y nodejs
RUN npm install --global bower
WORKDIR /var/www/html
COPY install-composer.sh install-composer.sh
RUN bash ./install-composer.sh
COPY composer.json ./
COPY composer.lock ./
RUN composer install --no-scripts --no-autoloader
COPY . ./
RUN composer update
RUN composer install
COPY zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf
RUN mkdir -p /var/run/php/sock/
RUN sass resources/sass/style.scss:public/assets/stylesheets/style.css
RUN bower install --allow-root
RUN composer dump-autoload
RUN php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"
ONBUILD chown -R www-data:www-data .
RUN php artisan optimize && php artisan config:cache \
&& php artisan view:cache && php artisan view:clear
Most of the time I need to get into the container and run the php artisan optimize, view:cache and view:clear again even though they are in the Dockerfile so it shouldn't be necessary to do it all over again
Any commands that are being executed using RUN in the Dockerfile will be executed only during the build phase. If you wish to run them while starting a container so you don't have to run them manually then you need to use a script e.g. bash script that can be used as an ENTRYPOINT for your Dockerfile and then make this script execute the command that you should run to start the application. So your entrypoint.sh can look like this:
# entrypoint.sh
#!/usr/bin/env sh
...
php artisan optimize
php artisan config:cache
php artisan view:cache
php artisan view:clear
...
php artisan serve # or use exec "$#" and pass php artisan serve through CMD in Dockerfile
This will make every container that you start execute all of these commands before start serving your application.
Other links that you might want to check:
What is the difference between CMD and ENTRYPOINT in a Dockerfile?
What does set -e and exec “$#” do for docker entrypoint scripts?
You can also use the cmd:
sudo docker-compose exec php php /var/www/html/path_to_laravel_project_dir/artisan config:cache
it will execute the artisan cmd in the container.
Just ran into a problem of cache:clear with Laravel too (no Docker involved in my case)
Fact is : if Artisan has no rights to clear caches, it just silently fails, proudly telling you cache have been successfully cleared (sigh).
See https://github.com/laravel/framework/issues/1179 for more details
*In my case, adding simple "sudo" before my command did the trick... but I lost half an hour understanding the cause (what an introduction to Laravel/Artisan :p)
*I have a Laravel v6.5
I am using laravel forge to deploy the application. The form submission on the local server works fine. It finds the right route declared in the route file. But it does not work on the live server. On live server when I hit submit button I got "Whoops, looks like something went wrong." message.
What could be the reasons? I will highly appreciate your help. Thanks in advance.
Here are the routes declared:
Route::get('/training/seo/outreach/brochure','BrochureDownloadController#index');
Route::post('/training/seo/outreach/brochure','BrochureDownloadController#store');
Here is the code on form
<form class="js-validate" method="post" id="brochure_download" name="brochure_download" action="{{ action('BrochureDownloadController#store')}}">
{{ csrf_field()}}
Deploy Script ( On forge)
cd /home/forge/www.xponent.com.bd
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
composer dump-autoload
php artisan cache:clear
echo "" | sudo -S service php7.2-fpm reloadif [ -f artisan ]
then
php artisan migrate --force
fi
Update your script
Add php artisan config:cache
cd /home/forge/www.xponent.com.bd
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
composer dump-autoload
php artisan cache:clear
php artisan config:cache
echo "" | sudo -S service php7.2-fpm reloadif [ -f artisan ]
then
php artisan migrate --force
fi
Please run below command:
php artisan config:cache
php artisan cache:clear
php artisan view:clear
php artisan route:clear
post-update-cmd: Illuminate\Foundation\ComposerScripts::postUpdate
post-update-cmd: php artisan ide-helper:generate
Executing command (CWD): php artisan ide-helper:generate
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to undefined method Illuminate\Database\Connection::resolverFor()
Script php artisan ide-helper:generate handling the post-update-cmd event returned with error code 1
Try Using this command in cmd for faster composer install or update
// unix
php -m | grep xdebug
// windows
php -m | findstr xdebug
composer install --prefer-dist -vvv --profile
composer update --prefer-dist -vvv --profile
I just installed Laravel 5.4.* and I have error when I execute this command:
php artisan vendor:publish
vagrant#homestead:~/projects/xxxx_com$ php artisan vendor:publish
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'League\Flysystem\MountManager' not found
vagrant#homestead:~/projects/xxxx_com$
Have you got an idea?
Probably you added new package to composer.json but you haven't run composer install. So make sure you run:
composer install
and after that run
php artisan vendor:publish
You might need to update your composer, run composer update
and see if that help.