Skip to content

Completed version 1.2.5 #14

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
APP_NAME=PhpSlides
APP_VERSION=1.2.3
APP_VERSION=1.2.5
APP_DEBUG=true
APP_ENV=development
APP_URL=http://localhost
JWT_SECRET=

DB_CONN=mysql
DB_PORT=3306
DB_HOST=0.0.0
DB_HOST=0.0.0.0
DB_USER=root
DB_PASS=root
DB_PASS=
DB_BASE=phpslides

SMTP_HOST=smtp.example.com
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/.vscode
.log
.env
.env.dev
.env.development
log
access_log
requests.log
Expand Down
2 changes: 1 addition & 1 deletion .htaccess
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<IfModule mod_rewrite.c>
# Don't change this settings, instead edit the phpslides.config.json
# Don't change this settings, instead edit the configs.json
RewriteEngine On

# Accept Authorization Header
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ streamlining the development process and enhancing productivity.
- [Or Clone the Repository](#or-clone-the-repository)
- [Configuration](#configuration)
- [.env](#env)
- [phpslides.config.json](#phpslidesconfigjson)
- [configs.json](#configsjson)
- [Syntax](#syntax)
- [Creating Web Layouts](#creating-web-layouts)
- [Styling Web Layouts](#styling-web-layouts)
Expand Down Expand Up @@ -105,12 +105,12 @@ Edit the .env file to configure database settings, application settings, and oth

```bash
APP_NAME=PhpSlides
APP_SERVER=localhost
APP_URL=http://localhost
APP_VERSION=1.2.5
APP_DEBUG=true
APP_ENV=development
```

### phpslides.config.json
### configs.json

```json
{
Expand Down Expand Up @@ -217,16 +217,15 @@ project_root/<br>
│ ├── configs/<br>
│ ├── resources/<br>
│ │ └── views/<br>
│ │ └── errors/<br>
├── vendor/<br>
├── .env<br>
├── .env.example<br>
├── .htaccess<br>
├── composer.json<br>
├── configs.json<br>
├── LICENSE<br>
├── phpslides.config.json<br>
└── README.md
├── slide<br>
├── README.md<br>
└── slide

## Documentation

Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions app/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

namespace App\Middleware;

use Closure;
use PhpSlides\Web\JWT;
use PhpSlides\Http\Request;
use PhpSlides\Interface\MiddlewareInterface;

final class AuthMiddleware implements MiddlewareInterface
{
public function handle(Request $request, Closure $next)
{
$token = $request->auth->bearer;

if ($token && JWT::verify($token)) {
return $next($request);
}
return 'Invalid Token';
}
}
Empty file removed app/Middlewares/.gitignore
Empty file.
File renamed without changes.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
"autoload": {
"psr-4": {
"App\\": ["app/"],
"App\\Controllers\\": ["app/Controllers/api/"]
"App\\Controller\\": ["app/Controller/api/"]
}
},
"authors": [
{
"name": "Dave Conco",
"email": "concodave@gmail.com",
"role": "Developer",
"homepage": "https://dconco.github.io"
}
],
"require": {
"php": "^8.0",
"phpslides/framework": "^1.0.0-alpha"
"php": "^8.2",
"phpslides/framework": "^1.2.5"
},
"config": {
"optimize-autoloader": true,
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions src/bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

include dirname(__DIR__) . '/../vendor/autoload.php';

Application::configure(basePath: dirname(dirname(__DIR__)))
->routing(
api: __DIR__ . '/../routes/api.php',
web: __DIR__ . '/../routes/web.php'
)
->create();
/**
* --------------------------------------------------------------------
* This is the Bootstrap File in starting the application.
* The entry point for the PhpSlides project and functions.
* --------------------------------------------------------------------
*/
Application::configure(basePath: dirname(dirname(__DIR__)))->create();
8 changes: 8 additions & 0 deletions src/configs/jwt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'issuer' => [getenv('APP_URL')],
'audience' => [],
'algorithm' => 'HS256',
'secret_key' => getenv('JWT_SECRET')
];
4 changes: 3 additions & 1 deletion src/configs/middleware.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php

return [];
return [
'auth' => 'App\\Middleware\\AuthMiddleware'
];
6 changes: 4 additions & 2 deletions src/resources/views/app.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<body>
<div class="container">
<div class="logo">
<img src="<? asset('Assets::Logo.svg') ?>" alt="PhpSlides Logo">
<img src={{ asset('Assets::Logo.svg') }} alt="PhpSlides Logo">
</div>

<div class="description">
Expand All @@ -68,7 +68,9 @@
</p>
</div>

<a href="<? asset('any') ?>"><button class="btn">Navigate To Not Found Page</button></a>
<a href={{ asset('any') }}>
<button class="btn">Navigate To Not Found Page</button>
</a>
</div>
</body>

Expand Down
6 changes: 3 additions & 3 deletions src/resources/views/components/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="title" content="PhpSlides | PHP Framework" />

<link rel="apple-touch-icon" href="<? asset('Assets::Icon.png') ?>" sizes="234x234" />
<link rel="shortcut icon" href="<? asset('Assets::Icon.png') ?>" type="image/png" />
<link rel="icon" href="<? asset('Assets::Icon.png') ?>" type="image/png" />
<link rel="apple-touch-icon" href={{ asset('Assets::Icon.png') }} sizes="234x234" />
<link rel="shortcut icon" href={{ asset('Assets::Icon.png') }} type="image/png" />
<link rel="icon" href={{ asset('Assets::Icon.png') }} type="image/png" />

<!-- Internal Styling -->
<style>
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/errors/404.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<body>
<div class="container">
<h3 class="text">404 | Page Not Found</h3>
<a href="<? asset('') ?>"><button class="btn">Navigate Back To Dashboard</button></a>
<a href={{ asset('') }}><button class="btn">Navigate Back To Dashboard</button></a>
</div>
</body>

Expand Down
3 changes: 1 addition & 2 deletions src/routes/api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use PhpSlides\Http\Api;
use App\Controllers\UserController;

Api::v1()->route('/user', UserController::class);
Api::v1();
20 changes: 20 additions & 0 deletions src/routes/render.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use PhpSlides\Foundation\Render;
use PhpSlides\Loader\FileLoader;

/**
* -----------------------------------------------------
* Render all registered Routes here
* Any registered Routes format should be rendered
* before any routes can be executed.
* -----------------------------------------------------
*/
(new FileLoader())
->safeLoad(__DIR__ . '/web.php')
->safeLoad(__DIR__ . '/api.php')
->safeLoad(__DIR__ . '/forms.php');

Render::FormsRoute();
Render::ApiRoute();
Render::WebRoute();
2 changes: 1 addition & 1 deletion src/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* --------------------------------------------------------------------
* | Register all routes here to render according to request
* | Register web routes here to render according to request
* | NOTE - that browser or any other request cannot access any page
* | that are not coming from route, it redirects to 404
* --------------------------------------------------------------------
Expand Down