Skip to content

Instantly share code, notes, and snippets.

View shengyou's full-sized avatar

Shengyou Fan shengyou

View GitHub Profile
@shengyou
shengyou / helpers.php
Last active March 12, 2023 14:49
env() helper functions without Laravel framework
<?php
if (! function_exists('env')) {
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list
package chapter15
fun main() {
Game.play()
}
# 啟動 Docker Image,並把當前目錄掛載到 Docker Image 裡
docker run -it -v $PWD:/src albertcht/swoole:latest
# 檢查開發環境是否正確
php -v
php --ri swoole
# 進入 examples 目錄
cd /src
// 取得 Docker image
docker pull albertcht/swoole:latest
// 將課程範例檔從 GitHub Clone 回來
git clone git@github.com:albertcht/swoole-course-examples.git
// 進入工作目錄
cd swoole-course-examples
@shengyou
shengyou / phinx.php
Created October 4, 2016 15:56
setup phinx config using php instead of yaml file.
<?php
require __DIR__.'/bootstrap.php';
return [
'paths' => [
'migrations' => '%%PHINX_CONFIG_DIR%%/db/migrations',
'seeds' => '%%PHINX_CONFIG_DIR%%/db/seeds',
],
'environments' => [
# 啟動 Docker Image,並把當前目錄掛載到 Docker Image 裡
docker run -it -v $PWD:/src phpbrew/phpbrew:php7.3-minimum-zts
# 以下指令請在 Docker Image 裡執行
# 使用 PHPBrew 切換到 PHP 7.3
phpbrew use 7.3
# 檢查開發環境是否正確
php -v
php-config
docker pull phpbrew/phpbrew:php7.3-minimum-zts
git clone git@github.com:php/php-src.git
cd php-src
git checkout php-7.3.3