|
1 | | -# phpcore |
2 | | -PHP Core Framework is a simple and easy to use MVC framework for web application development. It has been developed for the ease of building web application in PHP with OOP and MVC framework. It could be useful for projects in education. |
3 | | - |
4 | | -## Quick start |
5 | | -1. Download PHP Core and copy to your project folder |
6 | | -2. Configure web server |
7 | | - * Apache server |
8 | | - |
9 | | - Modify .htaccess file of project as per following |
10 | | - ``` |
11 | | - RewriteEngine On |
12 | | - RewriteCond %{REQUEST_FILENAME} !-f |
13 | | - RewriteCond %{REQUEST_FILENAME} !-d |
14 | | - RewriteRule ^(.*)$ index.php?q=$1 [QSA,NC,L] |
15 | | - ``` |
16 | | - * Nginx server |
17 | | - |
18 | | - Insert following codes into your server configuration in nginx.conf |
19 | | - ``` |
20 | | - location / { |
21 | | - index index.html index.htm index.php; |
22 | | - if (!-e $request_filename) { |
23 | | - rewrite ^(.*)$ /index.php?q=$1; |
24 | | - } |
25 | | - } |
26 | | - ``` |
27 | | -3. Create a controller |
28 | | - * Create "controllers" folder in your project folder |
29 | | - * Create "home.php" in "controllers" folder |
30 | | - ```php |
31 | | - <?php |
32 | | - class HomeController extends Controller { |
33 | | - public function Process() { |
34 | | - require_once($this->Views->GetModule($this->Request->Controller)); |
35 | | - } |
36 | | - } |
37 | | - ?> |
38 | | - ``` |
39 | | - * Declare new controller in module by modifying file "modules/controller.php" |
40 | | - ```php |
41 | | - <?php |
42 | | - // PHP Core |
43 | | - // Author: Hung Thanh Nguyen |
44 | | -
|
45 | | - // define folder for all of controllers, the name ControllerFolder should not be changed |
46 | | - define("ControllerFolder", "controllers/", true); |
47 | | -
|
48 | | - // declare your mvc controllers here, this declaration work like routes |
49 | | - $ControllerList = array ( |
50 | | - "" => array ("file" => "home.php", "class" => "HomeController"), |
51 | | - "home" => array ("file" => "home.php", "class" => "HomeController") |
52 | | - ); |
53 | | - ?> |
54 | | - ``` |
55 | | -4. Create a view |
56 | | - * Create "views" folder in your project folder |
57 | | - * Create "home.php" in "views" folder |
58 | | - ```php |
59 | | - <!DOCTYPE html> |
60 | | - <html lang="en"> |
61 | | - <head> |
62 | | - <meta charset="utf-8" /> |
63 | | - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
64 | | - <title>PHP Core Quick Start</title> |
65 | | - </head> |
66 | | - <body> |
67 | | - <h1>PHP Core Quick Start</h1> |
68 | | - </body> |
69 | | - </html> |
70 | | - ``` |
71 | | - * Declare new view in module by modifying file "modules/view.php" |
72 | | - ```php |
73 | | - <?php |
74 | | - // PHP Core |
75 | | - // Author: Hung Thanh Nguyen |
76 | | -
|
77 | | - // define folder for all of views, the name ViewFolder should not be changed |
78 | | - define("ViewFolder", "views/", true); |
79 | | -
|
80 | | - // declare views here |
81 | | - $ViewList = array ( |
82 | | - "" => array ("file" => "home.php"), |
83 | | - "home" => array ("file" => "home.php") |
84 | | - ); |
85 | | - ?> |
86 | | - ``` |
87 | | - |
| 1 | +# phpcore |
| 2 | +PHP Core Framework is a simple and easy to use MVC framework for web application development. It has been developed for the ease of building web application in PHP with OOP and MVC framework. It could be useful for projects in education. |
| 3 | + |
| 4 | +## Quick start |
| 5 | +1. Download PHP Core and copy to your project folder |
| 6 | +2. Configure web server |
| 7 | + * Apache server |
| 8 | + Modify .htaccess file of project as per following |
| 9 | + ``` |
| 10 | + RewriteEngine On |
| 11 | + RewriteCond %{REQUEST_FILENAME} !-f |
| 12 | + RewriteCond %{REQUEST_FILENAME} !-d |
| 13 | + RewriteRule ^(.*)$ index.php?q=$1 [QSA,NC,L] |
| 14 | + ``` |
| 15 | + * Nginx server |
| 16 | + Insert following codes into your server configuration in nginx.conf |
| 17 | + ``` |
| 18 | + location / { |
| 19 | + index index.html index.htm index.php; |
| 20 | + if (!-e $request_filename) { |
| 21 | + rewrite ^(.*)$ /index.php?q=$1; |
| 22 | + } |
| 23 | + } |
| 24 | + ``` |
| 25 | +3. Create a controller |
| 26 | + * Create "controllers" folder in your project folder |
| 27 | + * Create "home.php" in "controllers" folder |
| 28 | + ```php |
| 29 | + <?php |
| 30 | + class HomeController extends Controller { |
| 31 | + public function Process() { |
| 32 | + require_once($this->Views->GetModule($this->Request->Controller)); |
| 33 | + } |
| 34 | + } |
| 35 | + ?> |
| 36 | + ``` |
| 37 | + * Declare new controller in module by modifying file "modules/controller.php" |
| 38 | + ```php |
| 39 | + <?php |
| 40 | + // PHP Core |
| 41 | + // Author: Hung Thanh Nguyen |
| 42 | +
|
| 43 | + // define folder for all of controllers, the name ControllerFolder should not be changed |
| 44 | + define("ControllerFolder", "controllers/", true); |
| 45 | +
|
| 46 | + // declare your mvc controllers here, this declaration work like routes |
| 47 | + $ControllerList = array ( |
| 48 | + "" => array ("file" => "home.php", "class" => "HomeController"), |
| 49 | + "home" => array ("file" => "home.php", "class" => "HomeController") |
| 50 | + ); |
| 51 | + ?> |
| 52 | + ``` |
| 53 | +4. Create a view |
| 54 | + * Create "views" folder in your project folder |
| 55 | + * Create "home.php" in "views" folder |
| 56 | + ```php |
| 57 | + <!DOCTYPE html> |
| 58 | + <html lang="en"> |
| 59 | + <head> |
| 60 | + <meta charset="utf-8" /> |
| 61 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 62 | + <title>PHP Core Quick Start</title> |
| 63 | + </head> |
| 64 | + <body> |
| 65 | + <h1>PHP Core Quick Start</h1> |
| 66 | + </body> |
| 67 | + </html> |
| 68 | + ``` |
| 69 | + * Declare new view in module by modifying file "modules/view.php" |
| 70 | + ```php |
| 71 | + <?php |
| 72 | + // PHP Core |
| 73 | + // Author: Hung Thanh Nguyen |
| 74 | +
|
| 75 | + // define folder for all of views, the name ViewFolder should not be changed |
| 76 | + define("ViewFolder", "views/", true); |
| 77 | +
|
| 78 | + // declare views here |
| 79 | + $ViewList = array ( |
| 80 | + "" => array ("file" => "home.php"), |
| 81 | + "home" => array ("file" => "home.php") |
| 82 | + ); |
| 83 | + ?> |
| 84 | + ``` |
0 commit comments