Domestic PHP development framework myqee quick start tutorial, myqee quick start tutorial
I. environment.
My environment is the flagship version of win7 32bit. xampp1.7.4 (php version 1.8.x is too high, I personally think php 5.3X is more practical) + the latest version of mq. The focus is on configuring virtual machines,
Reference http://www.bkjia.com/article/52123.htm
The local xampp is installed on the D Drive and my configuration is provided: virtual machine configuration file path D: \ xampp \ apache \ conf \ extra \ httpd-vhosts
Copy codeThe Code is as follows:
# Mq
<VirtualHost *: 80>
DocumentRoot "D:/xampp/htdocs/mq /"
ServerName mq
<Directory "D:/xampp/htdocs/mq/">
Options Indexes FollowSymLinks between des ExecCGI
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *: 80>
DocumentRoot "D:/xampp/htdocs /"
ServerName localhost
</VirtualHost>
Host Configuration File Location
C: \ Windows \ System32 \ drivers \ etc \ hosts. ics
No hosts is found on the local machine. You can change hosts. ics.
2. Create a myqee Project
1. download the latest version of myqee, github you know.
Decompress the package to the D:/xampp/htdocs/mq folder (consistent with the virtual machine configuration ).
Change config. new. php to config. php.
Another. htacess is needed. I can't download it from github. The content that needs to be written in the official document is as follows:
Copy codeThe Code is as follows:
RewriteEngine On
RewriteCond % {REQUEST_FILENAME }! -F
RewriteCond % {REQUEST_FILENAME }! -D
RewriteRule. * index. php [PT, L]
Copy one copy to the wwwroot directory.
A. Create a project, open config. php In the root directory, and add an s project,
The configuration is as follows (before the default configuration)
Copy codeThe Code is as follows:
'S '=> array
(
'Name' => 'default Project', // name
'Dir' =>'s ', // directory
'Isuse' => true, // whether to enable
'Url' => '/',
),
B. Create the directory s under projects. Copy defautl and rename it for convenience.
Create a simple controller helloworld. controller. php In controllers under the s directory.
The content is as follows:
Copy codeThe Code is as follows:
<? Php
Class Controller_HelloWorld extends Controller
{
/**
* Test
*/
Public function action_default ()
{
Echo 'helloworld ';
}
}
Open the browser, enter mq/index. php/helloworld, and check hellowold.
In the development environment, we recommend that you enable the debug function of myqee and add it in php. ini.
Copy codeThe Code is as follows:
; [MyQEE]
Myqee. debug = On
Used with firefox + firebug.
3. display the content in the database.
Hello world is so simple that it doesn't make much sense in actual development. Let's take a look at it, read data from the database, and display it in the corresponding view.
A. Create a config. php file in the s root directory and write the corresponding database configuration. The content is as follows:
Copy codeThe Code is as follows:
<? Php
/** Database config */
$ Config ['database'] ['default'] = array
(
'Type' => 'mysql ',
'Connection' => array
(
'Hostname' => '2017. 0.0.1 ',
'Database' => 'rabbit ',
'Username' => 'rabbit ',
'Password' => '000000', 'persistent' => false,
),
'Table _ prefix' => '',
'Charset' => 'utf8 ',
'Caching' => false,
'Filing' => true,
);
Here, I have created an mq library in mysql and created a table wh_list.
The ddl of wh_list is as follows (the content is added by yourself ).
Copy codeThe Code is as follows:
Create table 'wh _ List '(
'Id' int (11) not null AUTO_INCREMENT,
'Name' varchar (32) COLLATE utf8_unicode_ci default null,
Primary key ('id '),
Unique key 'username' ('username') USING BTREE
) ENGINE = MyISAM default charset = utf8 COLLATE = utf8_unicode_ci;
B. Starting from model.
Create the models directory under the s directory, and create a wh. model. php with the following content:
Copy codeThe Code is as follows:
<? Php
Class Model_Wh extends Model
{
Static function get_list ()
{
$ Db = Database: instance ();
$ SQL = 'select * FROM wh_list ';
$ Arr = $ db-> query ($ SQL)-> as_array ();
Return $ arr;
}
}
Modify the helloworld controller as follows:
Copy codeThe Code is as follows:
<? Php
Class Controller_HelloWorld extends Controller
{
/**
* Test
*/
Public function action_default ()
{
$ View = new View ('wh ');
$ Arr = Model_Wh: get_list ();
$ View-> set ('wh ', $ arr );
$ View-> render ();
}
}
Don't be excited. If you click mq/index. php/helloworld in the browser just now, an error will be reported, and the view does not exist.
In views, create wh. view. php
The content is as follows:
Copy codeThe Code is as follows:
<? Php foreach ($ wh as $ w) {?>
<? Php echo $ w ['name']?>
<? Php }?>
Refresh and you will see the 'name' column in The wh_list table.
Oh, is it a sense of accomplishment.
The beginner's quick start tutorial is written here first, and the declaration is used only to give the beginner a Quick Start experience framework.
Which of the following is a better domestic PHP rapid development framework? Supports ajax and permission management
The php framework is just a standard class. You need to write classes yourself for ajax and permission management.
I personally recommend thinkphp because there are many tutorials on the Internet, so I am learning this framework.
I have a Qeephp question. I want to teach Dr. Liao-PHP framework development.
Ror is a framework developed using ruby, and qeephp is a framework developed using php... There is no native rapid development language