Search This Blog

2017/10/31

Set up laravel Homestead by vagrant

Prepare installation: VirtualBox 5.1; Vagrant; composer

$ vagrant box add laravel/homestead

$ cd ~

$ cd Homestead
$ git checkout v6.5.0

Init homestead
// Mac / Linux...
$ bash init.sh
// Windows...
$ init.bat

Modify file "Homestead.yaml"
folders:
    - map: /the/path/in/pc
      to: /home/vagrant/code

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ eval "$(ssh-agent -s)"
$ ssh-add -k ~/.ssh/id_rsa

$ cd /the/path/in/pc
$ composer create-project laravel/laravel projectName

Init and set up vagrant
$ vagrant up

Stop vagrant
$ vagrant halt

Connect to vagrant env
$ vagrant ssh

Restart vagrant
$ vagrant reload

2017/10/25

Install pip by python

CentOS:
yum -y install wget
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

Mac: Restart MySQL by command line


Apache:
sudo rm /Applications/XAMPP/xamppfiles/bin/mysql.server
sudo ln -s /Applications/XAMPP/xamppfiles/share/mysql/mysql.server /Applications/XAMPP/xamppfiles/bin/mysql.server 

2017/10/24

PHP: set timezone and date format

Use date_timezone_set to set 2017/10/24 00:00:00 in timezone Asia/Tokyo.
$date = '2017-10-24';
$timezone = 'Asia/Tokyo';
$tokyoTime = date_timezone_set(new DateTime($date), new DateTimeZone($timezone));
echo $tokyoTime;

If $date is null, $tokyoTime will be the time of right now in Tokyo.
Set $tokyoTime to null when $date is null.
$tokyoTime = empty($date) ? '' : date_timezone_set(new DateTime($date), new DateTimeZone($timezone));

Set format
$tokyoTime = empty($date) ? '' : date_format(date_timezone_set(new DateTime($date), new DateTimeZone($timezone)), 'Ymd H:i');

2017/10/12

Escape html <=> chr list

&#32; (Space) &#33; !
&#34; " &#35; #
&#36; $ &#37; %
&#38; & &#39; '
&#40; ( &#41; )
&#42; * &#43; +
&#44; , &#45; -
&#46; . &#47; /
&#48; 0 &#49;~&#57; 1~9
&#58; : &#59; ;
&#60; < &#61; =
&#62; > &#63; ?
&#64; @ &#65;~&#90; A~Z
&#91; [ &#92; \
&#93; ] &#94; ^
&#95; _ &#96; `
&#97;~&#122; a~z &#123; {
&#124; | &#125; }
&#126; ~ &#127; DEL
全角スペース:&#x3000;