1、安装composer前几天我看了一下zend framework 2的一些官方文档,也找了一些例子,可惜所有的资料少之甚少。于是我就开始去找这国外用的比较流行的PHP框架laravel,希望能够找到其合适的例子,而且我本就打算写一套后台管理系统,却正好发现了其扩展的包。Laravel-Administrator后台扩展包,提供了基本上通用的界面以及数据操作的例子,我们再也不需要自己去找模板了,特别在这个html5开始盛行的时候,一步步苦苦摸索实在太费时费力。做过后台的朋友不妨看看,这可以使你的工作更快快速和方便。
自从vim有统一的插件管理工具pathogen后,估摸着PHP的爱好者才想出了这么一个主意,统一的(依赖)管理器,开源插件进行统一管理也的确势在必行,不说废话了,首先看看怎么安装这个东西吧。
curl -s http://getcomposer.org/installer| php && mv composer.phar /usr/sbin/composer2、创建你的laravel项目
一条命令就帮你搭建好了基本的架构,是不是很方便呢?
composer create-PRoject laravel/laravel your-project-name #记得改成你的项目名称3、安装Laravel-Administrator包
cd your-project-name && vim composer.json #进入项目目录并编辑composer.json,把"frozennode/administrator": "dev-master"加入到"require"下
以下为最终的配置:
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keyWords": ["framework", "laravel"], "license": "MIT", "require": { "laravel/framework": "4.2.*", "frozennode/administrator": "dev-master" }, "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php artisan key:generate" ] }, "config": { "preferred-install": "dist" }, "minimum-stability": "stable"}4、配置包加载
vim app/config/app.php #找到数组providers,并在最后加入'Frozennode/Administrator/AdministratorServiceProvider',
以下为最终的配置:
<?phpreturn array( /* |-------------------------------------------------------------------------- | application Debug Mode |-------------------------------------------------------------------------- | | When your application is in debug mode, detailed error messages with | stack traces will be shown on every error that occurs within your | application. If disabled, a simple generic error page is shown. | */ 'debug' => true, /* |-------------------------------------------------------------------------- | Application URL |-------------------------------------------------------------------------- | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of | your application so that it is used when running Artisan tasks. | */ 'url' => 'http://pfadmins.local.com', /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which | will be used by the PHP date and date-time functions. We have gone | ahead and set this to a sensible default for you out of the box. | */ 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | */ 'locale' => 'en', /* |-------------------------------------------------------------------------- | Application Fallback Locale |-------------------------------------------------------------------------- | | The fallback locale determines the locale to use when the current one | is not available. You may change the value to correspond to any of | the language folders that are provided through your application. | */ 'fallback_locale' => 'en', /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is used by the Illuminate encrypter service and should be set | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | */ 'key' => '4g1RkrnrYg1UdkEHxUV3p8UBAlnTmWiZ', 'cipher' => MCRYPT_RIJNDAEL_128, /* |-------------------------------------------------------------------------- | Autoloaded Service Providers |-------------------------------------------------------------------------- | | The service providers listed here will be automatically loaded on the | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | */ 'providers' => array( 'Illuminate/Foundation/Providers/ArtisanServiceProvider', 'Illuminate/Auth/AuthServiceProvider', 'Illuminate/Cache/CacheServiceProvider', 'Illuminate/session/CommandsServiceProvider', 'Illuminate/Foundation/Providers/ConsoleSupportServiceProvider', 'Illuminate/Routing/ControllerServiceProvider', 'Illuminate/Cookie/CookieServiceProvider', 'Illuminate/Database/DatabaseServiceProvider', 'Illuminate/Encryption/EncryptionServiceProvider', 'Illuminate/Filesystem/FilesystemServiceProvider', 'Illuminate/Hashing/HashServiceProvider', 'Illuminate/Html/HtmlServiceProvider', 'Illuminate/Log/LogServiceProvider', 'Illuminate/Mail/MailServiceProvider', 'Illuminate/Database/MigrationServiceProvider', 'Illuminate/Pagination/PaginationServiceProvider', 'Illuminate/Queue/QueueServiceProvider', 'Illuminate/Redis/RedisServiceProvider', 'Illuminate/Remote/RemoteServiceProvider', 'Illuminate/Auth/Reminders/ReminderServiceProvider', 'Illuminate/Database/SeedServiceProvider', 'Illuminate/Session/SessionServiceProvider', 'Illuminate/Translation/TranslationServiceProvider', 'Illuminate/Validation/ValidationServiceProvider', 'Illuminate/View/ViewServiceProvider', 'Illuminate/Workbench/WorkbenchServiceProvider', 'Frozennode/Administrator/AdministratorServiceProvider', ), /* |-------------------------------------------------------------------------- | Service Provider Manifest |-------------------------------------------------------------------------- | | The service provider manifest is used by Laravel to lazy load service | providers which are not needed for each request, as well to keep a | list of all of the services. Here, you may set its storage spot. | */ 'manifest' => storage_path().'/meta', /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => array( 'App' => 'Illuminate/Support/Facades/App', 'Artisan' => 'Illuminate/Support/Facades/Artisan', 'Auth' => 'Illuminate/Support/Facades/Auth', 'Blade' => 'Illuminate/Support/Facades/Blade', 'Cache' => 'Illuminate/Support/Facades/Cache', 'ClassLoader' => 'Illuminate/Support/ClassLoader', 'Config' => 'Illuminate/Support/Facades/Config', 'Controller' => 'Illuminate/Routing/Controller', 'Cookie' => 'Illuminate/Support/Facades/Cookie', 'Crypt' => 'Illuminate/Suppor
新闻热点
疑难解答