If you are running Linux, you could consider using docker instead. That will allow you to create a small dev environment for each site. I have completely different php versions, settings and modules for each project
setting custom php version for valet linux dev site
Hi,
I just set up valet linux, but was wondering how i could setup custom php settings for each dev project like error reporting on etc.
Thank you,
TJ.
Thank you... that seems like a great idea. Do you also deploy sites using docker containers or do you provision whole servers? I am just trying to think of an efficient dev to deployment setup...
Actually I currently only use docker for development and 1 server (hosting multiple sites on different php versions.) The rest are just standalone Debian servers with everything set up manually (but exactly like the dev images).
For development I have a docker compose file and custom Dockerfiles to copy in my own config etc. For quickly testing out new setups I use "laravel served" (and use those docker files as base
Hi,
Thank you. I did not know about laravel served. That seems like a great idea to get started quickly.
I was trying to set it up and ran into an issue. It would be great if you could give me some direction with it.
Here are the steps I took:
mkdir laravel_served cd laravel_served/ composer require sinnbeck/laravel-served --dev
Then I tried running this command:
php artisan served:up
But, realized I had not created a laravel project yet.
Got this error: Could not open input file: artisan
I then created a laravel project:
composer create-project --prefer-dist laravel/laravel blog
Then went into this new blog directory
cd blog
and did
php artisan served:up
I now get this message:
There are no commands defined in the "served" namespace.
Any tips on how to progress from here and setup the first local stack via containers?
Thank you,
TJ.
Sure. I'll help you out. (I made served).
It works by running inside the project. So install it inside the new project
composer require sinnbeck/laravel-served --dev
I also suggest getting the config file to set it up how you like before your first run
php artisan vendor:publish --provider="Sinnbeck\LaravelServed\ServedServiceProvider"
Thank you. The local environment is up and running... Great job with served. Really beneficial to have this to get a dev environment up and running quickly.
I am new to laravel... could I ask you to recommend a getting started tutorial since I'd really value your input.
There is a lot of information out there, but maybe i can find an up to date on to get me up and running quickly? Preferably one with the latest version of laravel.
Regards,
TJ.
Happy to hear. It will gain more features in the future.
Start here https://laracasts.com/series/laravel-6-from-scratch
It's laravel 6 but almost everything will still be the same. And just ask if you run into problems
Great. Thank you. Going through these. They are very well made.
Quick question - if I don't want to use a database gui while development what would be the method to access the command line mysql client with in the mysql docker container?
Should I use the shell within the container to run the mysql client?
The reason I ask is because I am on a linux mint system and mysql workbench is really glitchy. I usually try and use the mysql command line or I add another container for phpmyadmin in dev.
So, when using served can I get access to the docker-compose.yml file to add that phpmyadmin container in that file or do I create it separately and then connect it to the network created by served?
You can enter directly into the container running mysql using this command
Replace mysql with the name for your own container (the key). It isnt actually ssh, but merely a docker exect -ti command :)
php artisan served:ssh mysql
Great thank you.
I'll just put these here as well if someone else reads this. I found these two additional ways to connect via command line.
Connect to mysql container
docker exec -it served_blog_mysql bash
tkhara@tkhara-lenovo:~$ docker exec -it served_blog_mysql bash
root@1aa3491d4b99:/# mysql -u root -p
Enter password: password
Connecting via command line
mysql -h 127.0.0.1 -P 33007 -u root -p laravel
But, this one is quite elegant thank you - php artisan served:ssh mysql
Best,
TJ.
P.S. I just tried running this and go the following output:
tkhara@tkhara-lenovo:~/envs/docker/laravel_served/blog$ php artisan served:ssh served_blog_mysql
Exception
Could not resolve served_blog_mysql
at vendor/sinnbeck/laravel-served/src/ServiceManager.php:154 150▕ if ($config = config('served.extras.' . $name)) { 151▕ return $this->resolve($name, Arr::get($config, 'service'), $config); 152▕ } 153▕ ➜ 154▕ throw new Exception('Could not resolve ' . $name); 155▕ } 156▕ } 157▕
+14 vendor frames
15 artisan:37 Illuminate\Foundation\Console\Kernel::handle()
served_blog_mysql is the name of my container and i tried this with the sha as well:
tkhara@tkhara-lenovo:~/envs/docker/laravel_served/blog$ php artisan served:ssh 1aa3491d4b99
Exception
Could not resolve 1aa3491d4b99
at vendor/sinnbeck/laravel-served/src/ServiceManager.php:154 150▕ if ($config = config('served.extras.' . $name)) { 151▕ return $this->resolve($name, Arr::get($config, 'service'), $config); 152▕ } 153▕ ➜ 154▕ throw new Exception('Could not resolve ' . $name); 155▕ } 156▕ } 157▕
+14 vendor frames
15 artisan:37 Illuminate\Foundation\Console\Kernel::handle()
This is my docker ps:
1aa3491d4b99 served/blog_mysql "docker-entrypoint.s…" 23 hours ago Up 5 hours 33060/tcp, 0.0.0.0:33007->3306/tcp served_blog_mysql bb809a4f5d0a served/blog_web "nginx -g 'daemon of…" 23 hours ago Up 5 hours 0.0.0.0:8095->80/tcp, 0.0.0.0:4443->443/tcp served_blog_web 69f2bef943d9 served/blog_php "docker-php-entrypoi…" 23 hours ago Up 5 hours 9000/tcp served_blog_php
Am I doing this wrong?
Thanks.
And sorry I couldn't format this better. I still haven't figured out how to get those code blocks in the formatting.
Please or to participate in this conversation.