Skip to content

Instantly share code, notes, and snippets.

@frankyonnetti
Last active May 29, 2021 20:36
Show Gist options
  • Select an option

  • Save frankyonnetti/286ce771e7fcf69efe549b5e5ce9684d to your computer and use it in GitHub Desktop.

Select an option

Save frankyonnetti/286ce771e7fcf69efe549b5e5ce9684d to your computer and use it in GitHub Desktop.
Valet

Laravel Valet

commands

valet trust # stop from always asking for password

valet restart

valet link SITENAME
valet secure SITENAME

valet unsecure SITENAME
valet unlink SITENAME

update

    subl /usr/local/etc/nginx/fastcgi_params
    
    composer global update
    valet install
    brew services restart mariadb
    valet restart
    

Brew update

brew services stop php && brew services start php
brew services stop mariadb && brew services start mariadb
valet restart

PHP

List loaded ini files.

php --ini

Switch PHP version

valet use php@7.4 - or valet use php

brew services stop php@7.4

Restart PHP

brew services restart php && valet restart


MariaDb

MariaDB (MySQL) is configured to only allow connections from localhost by default

To connect:

mysql -uroot

To have launchd start mariadb now and restart at login:

brew services stop mariadb
brew services start mariadb

Or, if you don't want/need a background service you can just run:

mysql.server start

Set root password

mysql_secure_installation -u USERNAME

PHP

php.ini

/usr/local/etc/php/7.x/

memory_limit:

subl /usr/local/etc/php/7.4/conf.d/php-memory-limits.ini

add to file:

; Defaullt is 30
max_execution_time = 300

; Max memory per instance
memory_limit = 512M

;The maximum size of an uploaded file.
upload_max_filesize = 512M

; Sets max size of post data allowed. 
; Changes to this will also need to be reflected in Nginx with client_max_body_size
; This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 512M

xdebug.ini

file locations:

/usr/local/etc/php/7.x/
/usr/local/Cellar/php@7.2/7.2.27/pecl/20170718/xdebug.so

mariaDB

set root password

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

database files:

cd /usr/local/var/mysql

my.cnf:

/usr/local/etc/my.cnf
#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]

[mysqld]
key_buffer_size = 32M
max_allowed_packet = 32M

[mysqldump]
max_allowed_packet = 32M

#
# include *.cnf from the config directory
#
!includedir /usr/local/etc/my.cnf.d

PHPMyAdmin

Valet Link

cd /usr/local/share/phpmyadmin
valet link phpmyadmin

Secret

/usr/local/etc/phpmyadmin.config.inc.php # line 18
$cfg['blowfish_secret']

Nginx

Error log:

/Users/USERNAME/.config/valet/Log/nginx-error.log

Too many headers sent - Drupal 8

Nginx / Valet - 502 Bad Gateway - upstream sent too big header

Files:

subl ~/.config/valet/Nginx/all.conf /usr/local/etc/nginx/fastcgi_params

Create ~/.config/valet/Nginx/all.conf with this:

proxy_buffer_size 1024k;
proxy_buffers 4 1024k;
proxy_busy_buffers_size 1024k;

Append this to /usr/local/etc/nginx/fastcgi_params

fastcgi_buffer_size 1024k;
fastcgi_buffers 4 1024k;
fastcgi_busy_buffers_size 1024k;


WordPress

cURL error 6

cURL error 6: Could not resolve: site.test (Domain name not found)

  • System Preferences -> Network -> Advanced -> DNS
  • Add 127.0.0.1 to DNS entries AT THE TOP.

MultiSite

Add driver

https://gist.github.com/frankyonnetti/d701dfec4ec86da400ccd9ad01147719


Favicon

laravel/valet#375 (comment)

file locations:

  • /usr/local/etc/nginx/valet/valet.conf
  • ~/.config/valet/Nginx/server.test

Add /public on the files paths inside your config file, and run valet restart:


location = /public/favicon.ico { access_log off; log_not_found off; }
location = /public/robots.txt  { access_log off; log_not_found off; }

Laravel Valet

Other links


PHP

Xdebug

Setup Xdebug in Laravel Valet with PHP Parsedown


DNS

TLDs for Testing, & Documentation Examples

.test
.example
.invalid
.localhost
  • ".test" is recommended for use in testing of current or new DNS related code.
  • ".example" is recommended for use in documentation or as examples.
  • ".invalid" is intended for use in online construction of domain names that are sure to be invalid and which it is obvious at a glance are invalid.

The ".localhost" TLD has traditionally been statically defined in host DNS implementations as having an A record pointing to the loop back IP address and is reserved for such use. Any other use would conflict with widely deployed code which assumes this use.


mysql/mariadb

Create:

/Library/LaunchDaemons/limit.maxfiles.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
          "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string>524288</string>
      <string>524288</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>

Email

Intercepting mail with MailHog in Laravel Valet

Install MailHog

brew install mailhog
brew services start mailhog

Local URL: http://localhost:8025

Tell Valet to use MailHog

  • Add config: /usr/local/etc/php/7.x/conf.d/smtp-mailhog.ini
  • File name: smtp-mailhog.ini
  • File Contents:
; Use Mailhog for mail delivery
sendmail_path=mailhog sendmail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment