Previously used Laravel, the framework comes with the artisan command, used to cool to explode. Now work needs, to learn fuelphp, first see the framework directory structure, there is Coposer.json framework can be used composer management, must also have their own command tools.
For beginners, you might want to start with a command to automatically generate files, and then look at the generated files to understand the basic CRUD operations.
First, the preparatory work
1, to use oil command to install composer first
Crossing network self-installing https://getcomposer.org/download/
2. Connect and create the database correctly
/fuel/app/config/development/db.php inside the database configuration
Here is the/fuel/app/directory structure
3. Open the Command editing tool and switch to the skeleton root directory.
Second, even if there is no local server, you can also access the site's Advanced command server
PHP Oil Server
Access to http://localhost:8000 is now available, but this state needs to be maintained (another window is opened to execute the other commands below). Ctrl-c can exit.
Iii. the most common commands for creating MVC and other required files generate
First look at what files can be created, and G is the abbreviation for generate.
PHP oil g Help
1, scaffold scaffolding, as the name implies, a command can create a series of MVC. A simple CRUD operation that requires only one command and does not need to write any code yourself.
Example: Create a Article MVC series file, title, content, author, reading four fields.
PHP Oil G scaffold article Title:varchar content:text Author:varchar reading:int
Has generated so many files, including controller, model, view, migration file, you can see the code specific additions and deletions to change the operation. (since no tables have been generated, the data cannot be imported and will continue to look down.) )
2. Controller
Example: Create a ccontroller category with four methods, index, store, update, delete
PHP Oil G Controller category Index store update delete
Build the controller file and the four view files corresponding to the method.
3. Model
Example: Create model category with Name field
PHP Oil G model category Name:varchar
Generate model and database-related migration files
Note: If migration is not required, the following parameters are added
PHP oil G model Tag Name:varchar--no-migration
If you need a soft delete, you need to Model_soft
PHP Oil G model Post title:varchar[50] User_id:int--soft-delete
4, presenter
PHP Oil G controller post action1 Action2--with-presenter
5, migration
? Perform file migrations and automatically create tables with migration files
PHP Oil Refine migrate
The database will have a table called migration, which records the files you want to migrate.
? Generate a migration file, or manipulate the table, in short, the filename should be the name.
PHP oil Generate migration create_users name:text email:string[50] password:string[125]//Create users Table PHP Oil Generate migration rename_table_users_to_accounts//Modify the Users table named accountsPHP oil generate mi Gration add_bio_to_accounts bio:text//Add field BioPHP oil Generate migration Delete_bio_from_ac Counts Bio:text//delete field bioPHP oil Generate migration rename_field_name_to_username_in_accounts Modify field names PHP oil Generate migration drop_accounts
6. Task
PHP Oil g task NewTask cmd1 cmd2
7. config
? PHP Oil g config Test Hello:world generates a normal configuration file test.php
? php Oil g config package generates package.php
? php Oil g config form--overwrite rewrite the configuration file under the core/config/directory.
8. Module
PHP Oil G Module Blog in the framework root directory will be more than one blog directory.
Iv. simple commands for performing some tasks refine
Also help to see the tasks that can be performed
PHP Oil Refine help
Above the red Box command can try oh, there are some very interesting effects
V. Command to install or uninstall package files
Package file resources are managed in configuration file package.php
PHP Oil Pack install Test-package test-package Package
PHP Oil Pack Uninstall test-package Uninstall package file
Six, convenient to execute PHP shortcut command console at any time
PHP Oil console will go into PHP environment, write PHP code freely
VII. Command test for unit testing
Used for unit test, etc. to be added later.
Fuelphp series------Oil Command