Skip to content

Commit 24cd703

Browse files
committed
rename this package to 'mvc' and update the namespaces
1 parent 7743563 commit 24cd703

File tree

7 files changed

+40
-34
lines changed

7 files changed

+40
-34
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# DevNet MVC Web Application Template
2-
This package is a DevNet Model-View-Controller web application template.
2+
This package is a Model-View-Controller web application template for DevNet Framework.
33

44
## Requirements
55
- [PHP](https://www.php.net/) version 8.0 or higher
66
- [Composer](https://getcomposer.org/) version 2.0 or higher
77

88
## Installation
9-
To create a DevNet Web MVC Application project using composer, run the following command in your terminal:
9+
You can use DevNet CLI to create a MVC web application project by running the following command in your terminal:
1010
```
11-
composer create-project devnet/mvc-template [project-Name]
11+
devnet new mvc --project [project-Name]
12+
```
13+
Or using composer
14+
```
15+
composer create-project devnet/mvc [project-Name]
1216
```
1317

1418
## Documentation

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"name": "devnet/mvc-template",
3-
"description": "DevNet Web Application (Model-View-Controller)",
2+
"name": "devnet/mvc",
3+
"description": "MVC Web Application",
44
"type": "project",
55
"license": "MIT",
66
"minimum-stability": "dev",
7-
"prefer-stable": true
7+
"prefer-stable": true,
8+
"require": {
9+
"devnet/core": "1.1.*"
10+
}
811
}

src/Controllers/AccountController.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
namespace Application\Controllers;
44

5-
use DevNet\System\Linq;
6-
use DevNet\System\Collections\ArrayList;
7-
use DevNet\Web\Endpoint\Controller;
8-
use DevNet\Web\Endpoint\IActionResult;
9-
use DevNet\Web\Endpoint\Route;
10-
use DevNet\Web\Security\Claims\ClaimsIdentity;
11-
use DevNet\Web\Security\Claims\Claim;
12-
use DevNet\Web\Security\Authentication\AuthenticationScheme;
13-
use DevNet\Web\Security\Authentication\IAuthentication;
14-
use DevNet\Web\Security\Authorization\Authorize;
15-
use DevNet\Web\Security\Tokens\Csrf\Validate;
16-
use DevNet\Web\Http\HttpContext;
175
use Application\Models\Login;
186
use Application\Models\Registration;
197
use Application\Models\User;
8+
use DevNet\Core\Endpoint\Controller;
9+
use DevNet\Core\Endpoint\IActionResult;
10+
use DevNet\Core\Endpoint\Filters\Authorize;
11+
use DevNet\Core\Endpoint\Filters\ValidateAntiForgery;
12+
use DevNet\Core\Endpoint\Route;
13+
use DevNet\Http\Message\HttpContext;
14+
use DevNet\Security\Claims\ClaimsIdentity;
15+
use DevNet\Security\Claims\Claim;
16+
use DevNet\Security\Authentication\AuthenticationScheme;
17+
use DevNet\Security\Authentication\IAuthentication;
18+
use DevNet\System\Collections\ArrayList;
19+
use DevNet\System\Linq;
2020

2121
class AccountController extends Controller
2222
{
@@ -45,7 +45,7 @@ public function register(): IActionResult
4545
return $this->view();
4646
}
4747

48-
#[Validate]
48+
#[ValidateAntiForgery]
4949
#[Route(path: '/account/create', method: 'POST')]
5050
public function create(Registration $form): IActionResult
5151
{
@@ -78,7 +78,7 @@ public function login(): IActionResult
7878
return $this->view();
7979
}
8080

81-
#[Validate]
81+
#[ValidateAntiForgery]
8282
#[Route(path: '/account/authenticate', method: 'POST')]
8383
public function authenticate(Login $form): IActionResult
8484
{

src/Controllers/HomeController.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
namespace Application\Controllers;
44

5-
use DevNet\Web\Endpoint\Controller;
6-
use DevNet\Web\Endpoint\IActionResult;
7-
use DevNet\Web\Endpoint\Route;
8-
use DevNet\Web\Http\HttpException;
5+
use DevNet\Core\Endpoint\Controller;
6+
use DevNet\Core\Endpoint\IActionResult;
7+
use DevNet\Core\Endpoint\Route;
98

109
class HomeController extends Controller
1110
{
@@ -32,16 +31,16 @@ public function error(): IActionResult
3231
return $this->redirect('/login');
3332
break;
3433
case 403:
35-
$error = new HttpException("Sorry! You don't have permission for this action.", 403);
34+
$error = new \Exception("Sorry! You don't have permission for this action.", 403);
3635
break;
3736
case 404:
38-
$error = new HttpException("Sorry! The page you are looking for cannot be found.", 404);
37+
$error = new \Exception("Sorry! The page you are looking for cannot be found.", 404);
3938
break;
4039
case 405:
41-
$error = new HttpException("Sorry! Your request method is not allowed.", 405);
40+
$error = new \Exception("Sorry! Your request method is not allowed.", 405);
4241
break;
4342
default:
44-
$error = new HttpException("Woops! Looks like something went wrong.", 500);
43+
$error = new \Exception("Woops! Looks like something went wrong.", 500);
4544
break;
4645
}
4746

src/Program.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Application;
44

5-
use DevNet\Web\Extensions\ApplicationBuilderExtensions;
6-
use DevNet\Web\Extensions\ServiceCollectionExtensions;
7-
use DevNet\Web\Hosting\WebHost;
5+
use DevNet\Core\Extensions\ApplicationBuilderExtensions;
6+
use DevNet\Core\Extensions\ServiceCollectionExtensions;
7+
use DevNet\Core\Hosting\WebHost;
88

99
class Program
1010
{
@@ -17,7 +17,7 @@ public static function main(array $args = [])
1717
});
1818

1919
$services->addAuthorization();
20-
$services->addAntiforgery();
20+
$services->addAntiForgery();
2121
});
2222

2323
$host = $builder->build();

src/Views/Account/login.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="text-center mt-3">
2626
Don't have an account? <a href="/register">Sign Up.</a>
2727
</div>
28-
<input type="hidden" name="X-CSRF-TOKEN" value="<?= $this->Antiforgery->getToken() ?>" />
28+
<input type="hidden" name="X-CSRF-TOKEN" value="<?= $this->AntiForgery->getToken() ?>" />
2929
</form>
3030
</div>
3131
</div>

src/Views/Account/register.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="d-grid gap-2">
2626
<button type="submit" class="btn btn-info text-white">Register</button>
2727
</div>
28-
<input type="hidden" name="X-CSRF-TOKEN" value="<?= $this->Antiforgery->getToken() ?>" />
28+
<input type="hidden" name="X-CSRF-TOKEN" value="<?= $this->AntiForgery->getToken() ?>" />
2929
</form>
3030
</div>
3131
</div>

0 commit comments

Comments
 (0)