Questions tagged «global-state»

8
Laravel:在哪里存储全局数组的数据和常量?
我刚刚开始与Laravel合作。我需要使用Laravel 4作为基本框架来重写几年前制作的整个系统。在我的旧系统中,我曾经有一个constant.php声明了一些常量的globals.php文件,以及一个包含许多数组集(例如,类别状态,事件类型,语言等)的文件。这样,我可以使用类似 foreach ( $langs as $code => $domain ) { // Some stuff } 我应用中的任何地方。 我的问题是,如何才能以所谓的“ laravel方式”存储该信息。我尝试使用某种对象来存储此信息,将其设置为服务并为其创建外观: app / libraries / Project / Constants.php namespace PJ; class Constants { public static $langs = [ 'es' => 'www.domain.es', 'en' => 'www.domain.us', 'uk' => 'www.domain.uk', 'br' => 'www.domain.br', 'it' => 'www.domain.it', …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.