Home  >  Article  >  Backend Development  >  Laravel中命名空间的运用

Laravel中命名空间的运用

WBOY
WBOYOriginal
2016-06-20 12:57:501792browse

Laravel中自己封装了一个独特的命名空间,可以让开发者在View中能使用特定命名空间。

View::addNamespace('Theme', '/views/theme/');

那么我们就可以在View::make()中进行运用了,比如

return View::make("Theme::templates.message",array('message'=>'我是消息'));

因为添加了Theme的命名空间,那么在View::make中就会相应的查找/views/theme/templates/message.blade.php文件。


使用这种方法添加命名空间,简单粗暴。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn