Skip to content

Instantly share code, notes, and snippets.

@nd3w
nd3w / php.ini for development
Created April 27, 2019 23:22
PHP configuration for development machine
; For dev only
expose_php=Off
log_errors=On
error_log=/var/log/httpd/php_scripts_error.log
file_uploads=On
;open_basedir="/var/www/html/"
error_reporting = E_ALL
; Should be 'off' on prod server
allow_url_fopen=On
@nd3w
nd3w / linux-commands.txt
Last active April 2, 2024 07:40
A Collection of Useful Linux Commands
Backup with bunzip
tar cvfj file.tar.bz2 *
tar cvfj file.tar.bz2 /path/to/directory_to_backup/
Extract from bunzip to directory 'archive'
tar -xvf archive.tar.bz2 ./
Compress multi directories into each own compressed files
for i in */; do zip -r "${i%/}.zip" "$i"; done
for i in */; do tar -czvf "${i%/}.tar.gz" "$i"; done
@nd3w
nd3w / gist:ff2b06464121d1aabec7287f37f00d1a
Last active August 19, 2019 03:01
Linux Aliases to Switch Amongs PHP Versions
Assuming I have three different PHP versions on my system:
1. PHP 5.6
2. PHP 7.1
3. PHP 7.2
To switch two between versions, add these aliases into your ~/.bashrc file:
alias php5671='sudo a2dismod php5.6 ; sudo a2enmod php7.1 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php'
alias php5672='sudo a2dismod php5.6 ; sudo a2enmod php7.2 ; sudo service apache2 restart ; echo 3 | sudo update-alternatives --config php'
@nd3w
nd3w / php-snippets.md
Last active March 15, 2024 15:45
PHP Snippets

Dump all PHP variables

$all_vars = get_defined_vars();
print_r($all_vars);

Create an array for a range (e.g: array with number from 1 to 9)

$number = 9;

for ($i = 1; $i <= $number; ++$i) {