Laravel Homestead -- The missing manual part 1 -- Site Parameters
Joe • February 23, 2018
laravel linux projects ubuntu vagrantIn the early days of Homestead there used to be a "params" option at the top level of your Homestead.yaml file. These parameters would be copied into the environment for the virtual machine just like you would set environment variables on your production systems. Laravel ultimately moved to using ".env" files and this feature was removed from Homestead.
Some users pushed back and still wanted to be able to easily push parameters to the individual site's configuration file (virtual host file) so a new feature was implemented where you could add a "params" key to your Homestead.yaml site definition and they would be copied into the virtual host configuration file. To get started using this feature simply add the "params" block to a site definition in Homestead.yaml:
sites:
- map: qs.test
to: /home/vagrant/qs/public
params:
- key: key_1
value: value_1
- key: key_2
value: value_2
Run "vagrant destroy && vagrant up" and when the machine comes back up, we can inspect our virtual host file at "/etc/nginx/sites-available/qs.test":
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param key_1 value_1;
fastcgi_param key_2 value_2;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
This feature also works for sites using Apache instead of Nginx.
As Seen On
Recent Posts
- PHP to Rust via Copilot
- Compiling Python 3.12 from Source Tarball on Linux
- HTML Form Processing with PHP - php[architect] Magazine August 2014
- The Workshop: Local Dev with Lando - php[architect] Magazine November 2022
- Getting back into the swing of things
- All Posts
Categories
- ansible
- apache
- applesilicon
- aws
- blackwidow
- cakephp
- community
- composer
- conferences
- copilot
- data-storage
- day-job
- devops
- docker
- fpv
- general
- github
- givecamp
- homestead
- jigsaw
- joindin
- keyboard
- laravel
- learning
- linux
- maker
- mamp
- mentoring
- music
- nonprofit
- opensource
- packages
- php
- phparch
- projects
- provisioning
- python
- razer
- rust
- s3
- security
- slimphp
- speaking
- static-sites
- storage
- testing
- tiny-whoop
- today-i-learned
- training
- ubuntu
- vagrant
- version-control
- windows
- writing
- wsl
- wsl2
- zend-zray