public function actionMigrate()
{
// Keep current application
$oldApp = \Yii::$app;
// Load Console Application config
$config = require \Yii::getAlias('@app'). '/config/console.php';
new \yii\console\Application($config);
$result = \Yii::$app->runAction('migrate', ['migrationPath' => '@app/migrations/', 'interactive' => false]);
// Revert application
View VS Code PHP Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
/* | |
// Place your snippets for PHP here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Print to console": { | |
"prefix": "log", | |
"body": [ |
View PHP CLI Benchmark script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$startTime = time(); | |
$runSeconds = 5; | |
$rounds = 5; | |
$count = 0; | |
for ($i=0; $i<$rounds; $i++) { | |
while ((time()-$startTime) <= $runSeconds) { | |
serialize(['bar'=>'foo']); | |
$count ++; |
View Laravel 5 Resource Controller Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
class PhotoController extends Controller | |
{ | |
/** | |
* Display a listing of the resource. |
View yii2-migrate-by-web-controller.md
View codeigniter-set-env-for-cli.md
Codeigniter - Set environment when running in CLI mode
There are some ways to set environment when running in CLI mode for Codeigniter 3:
Set Var in Command Way:
$ CI_ENV="production" php index.php welcome/index
View yii2-mailer-set-layout.md
[Yii2] Yii2 mailer set or disable layout template
Yii2 Mailer is extended by yii-mail-basemailer, which the compose()
would render an mail view with default layout.
Set or Disable Mailer layout
[
View codeiginter-server-config.md
Codeigniter 3 server configuration for Nginx & Apache
Web Server Site Configuration
Recommended Apache Configuration
Use the following configuration in Apache's httpd.conf file or within a virtual host configuration. Note that you should set DocumentRoot
and ServerName
fit to your environment:
View csr.conf.md
Openssl commands:
openssl genrsa -out self-ssl.key
openssl req -new -key self-ssl.key -out self-ssl.csr -config csr.conf
openssl x509 -req -days 365 -in self-ssl.csr -signkey self-ssl.key -out self-ssl.crt -extensions req_ext -extfile csr.conf
Sign from Root CA:
openssl x509 -req -days 365 -extensions req_ext -extfile csr.conf -CA RootCA.crt -CAkey RootCA.key -in self-ssl.csr -out self-ssl.crt
View nginx-80-to-443.config.md
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
View composer-install-vcs.md
1. Create
Composer install package via VCS such as GitLab
(Private package requirement)
composer.json
:
1. Create {
"repositories": [
{
"type": "vcs",
OlderNewer