Laraveladministrator is a common background plug-in (PHP framework extension)

Source: Internet
Author: User
Tags zend framework value store
A few days ago, I read some official documents of zendframework2 and found some examples. Unfortunately, there is very little information. So I began to look for laravel, a popular PHP framework used in other countries, and hoped to find a suitable example. I was planning to write a background management system, but it just found its extended package. Laravel-Adminis

A few days ago, I read some official documents of zend framework 2 and found some examples. Unfortunately, there is very little information. So I began to look for laravel, a popular PHP framework used in other countries, and hoped to find a suitable example. I was planning to write a background management system, but it just found its extended package. Laravel-Adminis

A few days ago, I read some official documents of zend framework 2 and found some examples. Unfortunately, there is very little information. So I began to look for laravel, a popular PHP framework used in other countries, and hoped to find a suitable example. I was planning to write a background management system, but it just found its extended package. Laravel-Administrator backend extension package provides basic common interfaces and data operation examples. We no longer need to find templates ourselves, especially when html5 becomes popular, it is too time-consuming and laborious to find a step by step. If you have worked in the background, you may wish to take a look. This will make your work faster, faster, and more convenient.

1. Install composer

Since vim has a unified plug-in management tool pathogen, it is estimated that PHP enthusiasts have come up with such an idea that the unified (dependency) manager and open-source plug-ins for unified management are indeed imperative, let's not talk nonsense. First, let's take a look at how to install this thing.

curl -s http://getcomposer.org/installer| php && mv composer.phar /usr/sbin/composer

2. Create Your laravel Project

A command will help you build the basic architecture. Is it very convenient?

Composer create-project laravel/laravel your-project-name # Remember to change it to your project name

3. Install the Laravel-Administrator package

Cd your-project-name & vim composer. json # enter the project directory and edit composer. json to add "frozennode/administrator": "dev-master" to "require"

The final configuration is as follows:

{    "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. Configure package Loading

Vim app/config/app. php # Find the array providers and add 'frozennode \ Administrator \ administratorserviceprovider' at the end ',

The final configuration is as follows:

  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\Support\Facades\Crypt',        'DB'              => 'Illuminate\Support\Facades\DB',        'Eloquent'        => 'Illuminate\Database\Eloquent\Model',        'Event'           => 'Illuminate\Support\Facades\Event',        'File'            => 'Illuminate\Support\Facades\File',        'Form'            => 'Illuminate\Support\Facades\Form',        'Hash'            => 'Illuminate\Support\Facades\Hash',        'HTML'            => 'Illuminate\Support\Facades\HTML',        'Input'           => 'Illuminate\Support\Facades\Input',        'Lang'            => 'Illuminate\Support\Facades\Lang',        'Log'             => 'Illuminate\Support\Facades\Log',        'Mail'            => 'Illuminate\Support\Facades\Mail',        'Paginator'       => 'Illuminate\Support\Facades\Paginator',        'Password'        => 'Illuminate\Support\Facades\Password',        'Queue'           => 'Illuminate\Support\Facades\Queue',        'Redirect'        => 'Illuminate\Support\Facades\Redirect',        'Redis'           => 'Illuminate\Support\Facades\Redis',        'Request'         => 'Illuminate\Support\Facades\Request',        'Response'        => 'Illuminate\Support\Facades\Response',        'Route'           => 'Illuminate\Support\Facades\Route',        'Schema'          => 'Illuminate\Support\Facades\Schema',        'Seeder'          => 'Illuminate\Database\Seeder',        'Session'         => 'Illuminate\Support\Facades\Session',        'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait',        'SSH'             => 'Illuminate\Support\Facades\SSH',        'Str'             => 'Illuminate\Support\Str',        'URL'             => 'Illuminate\Support\Facades\URL',        'Validator'       => 'Illuminate\Support\Facades\Validator',        'View'            => 'Illuminate\Support\Facades\View',    ),);

5. Generate Laravel-Administrator Configuration

Php artisan config: publish frozennode/administrator # generate and configure vim app/config/packages/frozennode/administrator. php # You can edit the background parameters of this file.

6. Example of configuring Laravel-Administrator

If we do not know how to start without examples, let's take a look at the example given in this plug-in package.

Cd .. /# Return to the working directory git clone https://github.com/FrozenNode/Laravel-Administrator # download the plug-in cp Laravel-Administrator/examples/app/config/packages/frozennode/administrator. php your-project-name/app/config/packages/frozennode/administrator/cp Laravel-Administrator/examples/app/config/administrator your-project-name/app/config /- r cp Laravel-Administrator/examples/app/models your-project-name/app/-r cp Laravel-Administrator/examples/app/database/migrations/* your-project-name /app/database/migrations/mkdir-p your-project-name/public/packages/frozennode/administrator cp Laravel-Administrator/public/* your-project-name/public/packages /frozennode/administrator/-r

# Create a database # first, create the data you need based on your database configuration. Here we take mysql as an example cd your-project-name # Enter your project directory vim app/config/database. php

My configurations are as follows:

  PDO::FETCH_CLASS,    /*    |--------------------------------------------------------------------------    | Default Database Connection Name    |--------------------------------------------------------------------------    |    | Here you may specify which of the database connections below you wish    | to use as your default connection for all database work. Of course    | you may use many connections at once using the Database library.    |    */    'default' => 'mysql',    /*    |--------------------------------------------------------------------------    | Database Connections    |--------------------------------------------------------------------------    |    | Here are each of the database connections setup for your application.    | Of course, examples of configuring each database platform that is    | supported by Laravel is shown below to make development simple.    |    |    | All database work in Laravel is done through the PHP PDO facilities    | so make sure you have the driver for your particular database of    | choice installed on your machine before you begin development.    |    */    'connections' => array(        'sqlite' => array(            'driver'   => 'sqlite',            'database' => __DIR__.'/../database/production.sqlite',            'prefix'   => '',        ),        'mysql' => array(            'driver'    => 'mysql',            'host'      => 'localhost',            'database'  => 'pf_admindb',            'username'  => 'root',            'password'  => 'mysql',            'charset'   => 'utf8',            'collation' => 'utf8_unicode_ci',            'prefix'    => '',        ),        'pgsql' => array(            'driver'   => 'pgsql',            'host'     => 'localhost',            'database' => 'forge',            'username' => 'forge',            'password' => '',            'charset'  => 'utf8',            'prefix'   => '',            'schema'   => 'public',        ),        'sqlsrv' => array(            'driver'   => 'sqlsrv',            'host'     => 'localhost',            'database' => 'database',            'username' => 'root',            'password' => '',            'prefix'   => '',        ),    ),    /*    |--------------------------------------------------------------------------    | Migration Repository Table    |--------------------------------------------------------------------------    |    | This table keeps track of all the migrations that have already run for    | your application. Using this information, we can determine which of    | the migrations on disk haven't actually been run in the database.    |    */    'migrations' => 'migrations',    /*    |--------------------------------------------------------------------------    | Redis Databases    |--------------------------------------------------------------------------    |    | Redis is an open source, fast, and advanced key-value store that also    | provides a richer set of commands than a typical key-value systems    | such as APC or Memcached. Laravel makes it easy to dig right in.    |    */    'redis' => array(        'cluster' => false,        'default' => array(            'host'     => '127.0.0.1',            'port'     => 6379,            'database' => 0,        ),    ),);

To ensure that the database user, password, IP address, and port are correct, you must ensure that your database exists before executing the following command.

Php artisan migrate: install & php artisan migrate # create a database and a table # The following are some commands for creating a database table. For more information, see # php artisan migrate: make create_directors_table # php artisan migrate: make writable # php artisan migrate: make create_box_office # php artisan migrate: make create_actors # php artisan migrate: make writable # php artisan migrate: make create_theaters # php artisan migrate: make writable

7. Configure your website

This configuration is especially mentioned when zend framework 2 is configured last time, and the laravel configuration is identical.

Server {listen 80; server_name zf2.local.com; # domain name root/data/www/zf2/public; # add public to your website directory, that is, add public to the project directory. Otherwise, the access method varies with the index. php; # charset UTF-8; location ~ * \. (Js | ico | gif | jpg | png | css | jpeg | swf) $ {access_log off; expires 2d;} location/{if (! -F $ request_filename) {rewrite ^ (. +) $/index. php? $1 & last ;}} location ~ \. Php $ {# root/var/www/html/public; fastcgi_pass 127.0.0.1: 9000; # If the listening port of your php-fpm is not this, set fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; include fastcgi_params;} # deny access. htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\. Ht {deny all ;}}

8. start browsing your website

Bind the Server IP address to your domain name and start browsing. My address here is http://pfadmins.local.com/admin. Be sure to add admin, because the background url is in admin. Of course you can configure it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.