Skip to content

Commit f4248cd

Browse files
authored
Update README.md
1 parent 281139b commit f4248cd

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ phpcore framework is a simple and easy to use MVC framework for web application
3737
use phpcore\core\Route;
3838
3939
class Startup extends App {
40+
// declare api controllers
41+
public $ApiRoutes = array();
4042
4143
// declare web controllers
4244
public $WebRoutes = array(
@@ -48,6 +50,7 @@ phpcore framework is a simple and easy to use MVC framework for web application
4850
public function __construct() {
4951
try {
5052
parent::__construct();
53+
$this->Route->setApiRoutes($this->ApiRoutes);
5154
$this->Route->setWebRoutes($this->WebRoutes);
5255
}
5356
catch (Exception $e) {
@@ -57,6 +60,10 @@ phpcore framework is a simple and easy to use MVC framework for web application
5760
5861
public function process() {
5962
try {
63+
if ($this->Request->IsApi) {
64+
$this->useCors("*");
65+
}
66+
6067
$this->useMvc();
6168
}
6269
catch (Exception $e) {
@@ -67,7 +74,7 @@ phpcore framework is a simple and easy to use MVC framework for web application
6774
?>
6875
6976
```
70-
5. Create a HomeController [project folder]/src/server/controllers/HomeController.php
77+
5. Create HomeController [project folder]/src/server/controllers/HomeController.php
7178
```php
7279
<?php
7380
namespace phpcore\controllers;
@@ -114,17 +121,20 @@ Steps to create a Web API with phpcore framework.
114121
use phpcore\core\Route;
115122
116123
class Startup extends App {
117-
118124
// declare api controllers
119125
public $ApiRoutes = array(
120126
"namespace" => "phpcore\\controllers\\api\\",
121127
"getinfo" => array("controller" => "GetInfoController")
122128
);
123-
129+
130+
// declare web controllers
131+
public $WebRoutes = array();
132+
124133
public function __construct() {
125134
try {
126135
parent::__construct();
127136
$this->Route->setApiRoutes($this->ApiRoutes);
137+
$this->Route->setWebRoutes($this->WebRoutes);
128138
}
129139
catch (Exception $e) {
130140
throw $e;
@@ -367,17 +377,20 @@ This example will create a Web API that returns data from SQLite with Doctrine,
367377
use phpcore\core\Route;
368378
369379
class Startup extends App {
370-
371380
// declare api controllers
372381
public $ApiRoutes = array(
373382
"namespace" => "phpcore\\controllers\\api\\",
374383
"getinfo" => array("controller" => "GetInfoController")
375384
);
376-
385+
386+
// declare web controllers
387+
public $WebRoutes = array();
388+
377389
public function __construct() {
378390
try {
379391
parent::__construct();
380-
$this->Route->SetApiRoutes($this->ApiRoutes);
392+
$this->Route->setApiRoutes($this->ApiRoutes);
393+
$this->Route->setWebRoutes($this->WebRoutes);
381394
}
382395
catch (Exception $e) {
383396
throw $e;

0 commit comments

Comments
 (0)