-
on certain routes, remove this line from App\Http\Kernel 's middleware array: 'App\Http\Middleware\VerifyCsrfToken', If you want to use it elsewhere, add this line to $routeMiddleware : 'csrf' => also need to add the Form and HTML facades and service provider. Edit config/app.php , and add this line to the 'providers' array: Global IoC Bindings Views Blade Tag Changes Translation Files Public should be followed: The class namespace declaration must be on the same line as line as the class name. Functions and control structures must use Allman
0 码力 |
242 页 |
1.44 MB
| 1 年前 3
-
LazyCollection::make(function () { $handle = fopen('log.txt', 'r'); while (($line = fgets($handle)) !== false) { yield $line; } }) ->chunk(4) ->map(function ($lines) { return LogEntry::fromLines($lines); Capsule::table 方法 Eloquent 数组化 & toArray Eloquent BelongsTo::update 方法 Eloquent 主键类型 本地化 Lang::trans 和 Lang::transChoice 方法 本文档由学院君提供 学院君致力于提供优质 Laravel 中文学习资源:https://xueyuanjun.com 12 本地化 Lang::getFromJson Lang::trans & Lang::transChoice 方法 影响级别:中等 翻译器的 Lang::trans 和 Lang::transChoice 方法被重命名 为 Lang::get 和 Lang::choice 方法。 此外,如果你自行实现 了 Illuminate\Contracts\Translation\Translator 契约,需要 更新实现类的 trans 和 transChoice
0 码力 |
1442 页 |
14.66 MB
| 1 年前 3
-
当然,你可以在 message 方法中调用辅助函数 trans 来返回一个在语言文件中定义的错误消息: /** * Get the validation error message. * * @return string */ public function message() { return trans('validation.uppercase'); } some|[20,*] There are many', 之后,你可以使用 trans_choice 函数获取给定行数的语言行,在本例中,由于行数大于 1,将会返回翻译字符串的复数形式: echo trans_choice('messages.apples', 10); 还可以在复数字符串中定义占位符属性,这些占位符会被传递给 trans_choice 函数的第三个数组参数替换: 'minutes_ago' 'minutes_ago' => '{1} :value minute ago|[2,*] :value minutes ago', echo trans_choice('time.minutes_ago', 5, ['value' => 5]); 覆盖 Vendor 包的语言文件 有些扩展包可能会自己处理语言文件。你可以通过将自己的文件放在 resources/lang/vendor/{package}/{locale}
0 码力 |
377 页 |
14.56 MB
| 1 年前 3
-
你可以使用帮助函数 trans 从语言文件中获取行,该方法接收文件和语言行的键作为第一个参数, 例如,让我们在语言文件 resources/lang/messages.php 中获取语言行 welcome: echo trans('messages.welcome'); 当然如果你使用 Blade 模板引擎,可以使用{{ }}语法打印语言行或者使用 @lang 指令: {{ trans('messages trans('messages.welcome') }} @lang('messages.welcome') 如果指定的语言行不存在,trans 函数将返回语言行的键,所以,使用上面的例子,如果语言行 不存在的话,trans 函数将返回 messages.welcome。 替换语言行中的参数 如果需要的话,你可以在语言行中定义占位符,所有的占位符都有一个:前缀,例如,你可以用占 本文档由 216 位符名称定义一个 welcome 消息: 'welcome' => 'Welcome, :name', 要在获取语言行的时候替换占位符,传递一个替换数组作为 trans 函数的第二个参数: echo trans('messages.welcome', ['name' => 'Dayle']); 如果占位符都是大写的,或者首字母是大写的,那么相应的,传入的值也会保持和占位符格式一
0 码力 |
691 页 |
9.37 MB
| 1 年前 3
-
$name = $this->choice('What is your name?', ['Taylor', 'Dayle '], false); 3.4 编写输出 要将输出发送到控制台,使用 line,info, comment, question 和 error 方法,每个方法都会 使用相应的 ANSI 颜色以作标识。 要显示一条信息消息给用户,使用 info 方法。通常,在终端显示为绿色: error 方法。错误消息文本通常是红色: $this->error('Something went wrong!'); 如果你想要显示原生输出,可以使用 line 方法,该方法输出的字符不带颜色: $this->line('Display this on the screen'); 表格布局 table 方法使输出多行/列格式的数据变得简单,只需要将头和行传递给该方法,宽度和高 // FooBar trans() trans 函数使用本地文件翻译给定语言行: echo trans('validation.required'): 本文档由 Laravel 学院(LaravelAcademy.org)提供 Laravel 学院致力于提供优质 Laravel 中文学习资源 260 trans_choice() trans_choice 函数翻译带拐点的给定语言行:
0 码力 |
377 页 |
4.56 MB
| 1 年前 3
-
studly_case('foo_bar'); // FooBar trans() trans 函数使用本地文件翻译给定语言行: echo trans('validation.required'): trans_choice() trans_choice 函数翻译带拐点的给定语言行: $value = trans_choice('foo.bar', $count); 本文档由 你可以使用帮助函数 trans 从语言文件中获取行,该方法接收文件和语言行的键作为第一个 参数,例如,让我们在语言文件 resources/lang/messages.php 中获取语言行 welcome: echo trans('messages.welcome'); 当然如果你使用 Blade 模板引擎,可以使用{{ }}语法打印语言行: {{ trans('messages.welcome') welcome') }} 如果指定的语言行不存在,trans 函数将返回语言行的键,所以,使用上面的例子,如果语 言行不存在的话,trans 函数将返回 messages.welcome。 替换语言行中的参数 本文档由 Laravel 学院(LaravelAcademy.org)提供 239 如果需要的话,你可以在语言行中定义占位符,所有的占位符都有一个:前缀,例如,你可 以用占位符名称定义一个
0 码力 |
307 页 |
3.46 MB
| 1 年前 3
-
.. } ]); The GuzzleHttp\Event\ErrorEvent event object is emitted when an error occurs during a trans- fer. With this event, you have access to the request that was sent, the response that was received HTTP messages a client receives from a server after sending an HTTP request message. Start-Line The start-line of a response contains the protocol and protocol version, status code, and reason phrase. to work with various types of data all using a common interface. HTTP messages consist of a start-line, headers, and a body. The body of an HTTP message can be very small or extremely large. Attempting
0 码力 |
63 页 |
275.75 KB
| 11 月前 3
-
Working on a patch Submitting a pull request Coding Standards Language Adding New Features Indentation
Line Length Control Structures Comparison Function Calls Method Definition Method Chaining DocBlocks Including the action uses set() to pass data from the controller to the view (which we’ll create next). The
line sets the view variable called ‘posts’ equal to the return value of the find('all') method of the Post /app/View/Posts/index.ctp view to include a new “Add Post” link. Before the
, add the following line: Html->link( 'Add Post', array('controller' => 'posts', 'action' => 'add') 0 码力 |
1096 页 |
958.62 KB
| 1 年前 3
-
webserver’s PHP version must also be of 5.6 or higher, and should be the same version your command line interface (CLI) PHP is. 13 CakePHP Cookbook Documentation, Release 3.10 Getting CakePHP The easiest CakePHP is to use Composer. Composer is a simple way of installing CakePHP from your terminal or command line prompt. First, you’ll need to download and install Composer if you haven’t done so already. If you php Or, you can download composer.phar from the Composer website20. Then simply type the following line in your terminal from your installation directory to install the CakePHP application skeleton in the
0 码力 |
967 页 |
2.80 MB
| 1 年前 3
-
all .htaccess files. In the lighttpd configuration, make sure you’ve activated “mod_rewrite”. Add a
line: url.rewrite-if-not-file =( "^([^\?]*)(\?(.+))?$" => "/index.php?url=$1&$3" ) URL rewrite rules the action uses set() to pass data from the controller to the view (which we’ll create next). The
line sets the view variable called ‘posts’ equal to the return value of the find('all') method of the Post /app/View/Posts/index.ctp view to include a new “Add Post” link. Before the
, add the following line: Html->link( 'Add Post', array('controller' => 'posts', 'action' => 'add') ); 0 码力 |
820 页 |
2.52 MB
| 1 年前 3