如何在開發的過程中加入測試。
- Model
- Repository
- Controller
- Auth
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
<?php | |
// ------------------------------------------------------------------------------------- | |
// Add your JSON in the $input to generate Swagger-PHP annotation | |
// Inspired by: https://github.com/Roger13/SwagDefGen | |
// HOWTO: | |
// php -S localhost:8888 -t . | |
// http://localhost:8888/swagit.php | |
// ------------------------------------------------------------------------------------- |
<?php | |
Request::macro('validate', function ($rules, $messages = [], $customAttributes = []) { | |
$this->lastValidated = array_keys($rules); | |
(new class() { | |
use ValidatesRequests; | |
})->validate($this, $rules, $messages, $customAttributes); | |
}); |
<?php | |
class Model extends BaseModel { | |
public $defaultRuleAry = []; //預設規則 | |
public function validation() { //驗證輸入 | |
//根據 $this->defaultRuleAry 來驗證 | |
return true; | |
} | |
public function save(array $options = array()) |
<?xml version="1.0" encoding="UTF-8"?> | |
<ruleset name="MentorMate"> | |
<description> | |
The coding standard of the MentorMate team, based on the Generic, PSR2, | |
Squiz and Zend coding standards. | |
</description> | |
<arg name="colors"/> | |
<ini name="memory_limit" value="128M"/> |
// see also https://github.com/robmorgan/phinx/issues/364 | |
$phinxApp = new \Phinx\Console\PhinxApplication(); | |
$phinxTextWrapper = new \Phinx\Wrapper\TextWrapper($phinxApp); | |
$phinxTextWrapper->setOption('configuration', '/path/to/phinx.yml'); | |
$phinxTextWrapper->setOption('parser', 'YAML'); | |
$phinxTextWrapper->setOption('environment', 'development'); |
<?php | |
use ...; | |
class GeneratingArgumentsTest extends \PHPUnit_Framework_TestCase | |
{ | |
/** | |
* @var VariableArgumentCollectionFactory | |
* @Inject | |
*/ |
After installing, make sure the permissions are proper | |
sudo chmod -R g+w storage/ | |
sudo chown -R :www-data storage/ | |
Then modify the .htaccess file under yourProjectName/public/.htaccess | |
RewriteBase /yourProjectName/ | |
Then add an alias to the Apache conf | |
Alias /yourProjectName /var/www/whatever/yourProjectName/public |
<?php | |
$sig_check = 'sha1=' . hash_hmac('sha1', Request::getContent(), $_ENV['github_webhook_secret']); | |
if ($sig_check === Request::header('x-hub-signature')) { // php >=5.6 and above should use hash_equals() for comparison | |
// sigs match, do stuff | |
} |