2015年3月

备份下 sublime_text 配置

{
    "auto_indent": true,
    "color_scheme": "Packages/Monokai Extended/Monokai Extended Bright.tmTheme",
    "default_encoding": "UTF-8",
    "detect_indentation": true,
    "detect_slow_plugins": false,
    "draw_indent_guides": true,
    "draw_white_space": "selection",
    "ensure_newline_at_eof_on_save": true,
    "font_face": "XHei Mono.Minglan.Consolas.pl",
    "font_size": 10,
    "highlight_line": true,
    "ignored_packages":
    [
        "DocBlockr",
        "Vintage",
        "Blade Snippets",
        "BracketHighlighter",
        "ConvertToUTF8"
    ],
    "indent_guide_options":
    [
        "draw_normal"
    ],
    "rulers":
    [
        80,
        100
    ],
    "tab_completion": true,
    "tab_size": 4,
    "translate_tabs_to_spaces": false,
    "trim_trailing_white_space_on_save": false,
    "word_wrap": "auto",
    "wrap_width": 100,
    "default_encoding": "UTF-8",
    "default_line_ending": "unix",
    "ensure_newline_at_eof_on_save": true
}

PHP可选参数与可变参数

参考文档:http://php.net/manual/zh/functions.arguments.php

可选参数函数

我们尝试计算3个或2个数字之和,可以使用下面示例代码:

function sum($a, $b, $c = 0){
    return $a + $b + $c;
}
echo sum(1, 2);  //计算1+2=3
echo sum(1, 2, 3);  //计算1+2+3=6

其中,sum(1, 2)只传入 2 个变量 $a 与 $b ,第三个变量 $c 是可选的,因为它存在默认值 0 。

- 阅读剩余部分 -

使用 PHP-CS-Fixer 规范PHP代码

参考文章:https://phphub.org/topics/547

良好的代码规范可以提高代码可读性,团队沟通维护成本。最推荐大家遵守的是 php-fig(PHP Framework Interop Group) 组织定义的 PSR-1PSR-2 两个。不了解的同学可以先通过连接点击过去阅读下。

PHP-CS-Fixer

项目地址: https://github.com/FriendsOfPHP/PHP-CS-Fixer

phar档案下载地址:http://get.sensiolabs.org/php-cs-fixer.phar

使用

由于国内网络问题,建议直接下载php-cs-fixer.phar

使用 fix 指令修复文件夹或文件的代码风格:

php php-cs-fixer.phar fix /path/to/dir
php php-cs-fixer.phar fix /path/to/file

使用 --level 选项设置修复至的「规范」:

php php-cs-fixer.phar fix /path/to/project --level=psr0
php php-cs-fixer.phar fix /path/to/project --level=psr1
php php-cs-fixer.phar fix /path/to/project --level=psr2
php php-cs-fixer.phar fix /path/to/project --level=symfony

更多使用方式参见 Usage

基于 Laravel 5 构建的博客

此前已发过类似的贴子,但当时是 Laravel 4 版且没有公布源码,故关注的人较少。现在源码初版已发布到 GitHub ,欢迎大家关注,Star,Fork,希望本源码能起到抛砖引玉的作用。有任何问题可发起 Issue 或加群交流。

GitHub 地址:https://github.com/douyasi/yascmf
演示网站:http://www.yas.so/

20150312113729.jpg

安装说明请看 readme 文档


- 阅读剩余部分 -