├── public
├── favicon.ico
└── css
│ └── style.css
├── views
├── index.twig
├── error.twig
└── layout.twig
├── .gitignore
├── .htaccess
├── composer.json
├── index.php
├── LICENSE
└── README.md
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/views/index.twig:
--------------------------------------------------------------------------------
1 | {% extends 'layout.twig' %}
2 |
3 | {% block body %}
4 |
{{title}}
5 | Welcome to {{title}}
6 | {% endblock %}
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /vendor
3 | /.idea
4 | /.vscode
5 | .env
6 | .env.backup
7 | .env.production
8 | .phpunit.result.cache
9 | composer.lock
10 |
--------------------------------------------------------------------------------
/views/error.twig:
--------------------------------------------------------------------------------
1 | {% extends 'layout.twig' %}
2 |
3 | {% block body %}
4 | {{message}}
5 | {{status}}
6 | {{stack}}
7 | {% endblock %}
8 |
--------------------------------------------------------------------------------
/.htaccess:
--------------------------------------------------------------------------------
1 | # REDIRECT ALL REQUEST TO INDEX.PHP
2 | RewriteEngine on
3 | RewriteCond %{REQUEST_FILENAME} !-f
4 | RewriteCond %{REQUEST_FILENAME} !-d
5 | RewriteRule ^(.*)$ /index.php [L,QSA]
--------------------------------------------------------------------------------
/public/css/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding: 40px;
3 | font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
4 | }
5 |
--------------------------------------------------------------------------------
/views/layout.twig:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ title }}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "unicframework/unic",
3 | "type": "project",
4 | "description": "Unic is a high performance, open source web framework.",
5 | "keywords": [
6 | "unic",
7 | "unic framework",
8 | "php framework",
9 | "web framework",
10 | "mvc framework"
11 | ],
12 | "homepage": "https://unicframework.github.io/docs",
13 | "support": {
14 | "issues": "https://github.com/unicframework/unic/issues",
15 | "source": "https://github.com/unicframework/unic"
16 | },
17 | "license": "MIT",
18 | "authors": [
19 | {
20 | "name": "Rajkumar Dusad",
21 | "homepage": "https://github.com/rajkumardusad"
22 | }
23 | ],
24 | "require": {
25 | "php": ">=7.4",
26 | "unicframework/framework": "~1.0.0",
27 | "twig/twig": "~3.4"
28 | },
29 | "minimum-stability": "stable",
30 | "prefer-stable": true
31 | }
32 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | set('views', __DIR__ . '/views');
10 | $app->set('view_engine', 'twig');
11 |
12 | // Set public path and static files directory
13 | $app->use($app->static('/', __DIR__ . '/public'));
14 |
15 | // Routes
16 | $app->get('/', function ($req, $res) {
17 | $res->render('index.twig', [
18 | 'title' => 'Unic',
19 | ]);
20 | });
21 |
22 | $app->get('/api', function ($req, $res) {
23 | $res->json([
24 | 'status' => "ok",
25 | ]);
26 | });
27 |
28 | // Error handler middleware
29 | $app->use(function ($err, $req, $res, $next) {
30 | $res->status(500)
31 | ->render('error.twig', [
32 | 'message' => $err->getMessage(),
33 | 'stack' => $err->getTraceAsString(),
34 | 'status' => 500,
35 | ]);
36 | });
37 |
38 | $app->start();
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 unic-framework
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Unic Framework
2 |
3 |
4 |
5 |
6 |
7 | Unic is a high performance, open source web application framework.
8 | Unic framework is fast, minimal and unopinionated web framework inspired by express.
9 | Unic is simple and flexible and provide lots of features to create apis and web application quickly.
10 |
11 | ## Features
12 | - Fast and flexible.
13 | - Extremely light weight.
14 | - Minimal and unopinionated.
15 | - Simple and robust routing.
16 | - Robust middlewares.
17 |
18 | ## Installation
19 |
20 | Unic web framework is for PHP, so it's requires PHP 7.4 or newer. now you won’t need to setup anything just yet.
21 |
22 | - Install `composer` if you have not installed.
23 |
24 | ```shell
25 | composer create-project unicframework/unic blog
26 | ```
27 |
28 | It will create a `blog` project for you.
29 |
30 |
31 | ## Simple Example
32 |
33 | A simple `Hello, World` web application in unic framework.
34 |
35 | ```php
36 | use Unic\App;
37 |
38 | $app = new App();
39 |
40 | $app->get('/', function($req, $res) {
41 | $res->send('Hello, World!');
42 | });
43 |
44 | $app->get('/api', function($req, $res) {
45 | $res->json([
46 | 'status' => 'Ok',
47 | ]);
48 | });
49 |
50 | $app->start();
51 | ```
52 |
53 | ## Documentation
54 |
55 | - Learn more about Unic from [Documentation](https://github.com/unicframework/docs/) file.
56 | - Documentation : [https://unicframework.github.io/docs](https://unicframework.github.io/docs)
57 |
58 | ## License
59 |
60 | [MIT License](LICENSE)
61 |
--------------------------------------------------------------------------------