Skip to content

Commit

Permalink
creating app
Browse files Browse the repository at this point in the history
  • Loading branch information
khamdullaevuz committed May 21, 2023
0 parents commit 8b21bef
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
vendor
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# app

## Run
```shell
php run serve
```
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "esoftuz/app",
"description": "App",
"type": "project",
"require": {
"esoftuz/framework": "1.0.0"
},
"autoload": {
"psr-4": {
"Controllers\\": "controllers"
},
"files": ["routes/web.php", "routes/console.php"]
},
"license": "MIT",
"authors": [
{
"name": "khamdullaevuz",
"email": "[email protected]"
}
],
"minimum-stability": "dev"
}
59 changes: 59 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Controllers;

use Esoftuz\Framework\Controller;

class HomeController extends Controller
{
public function index(): string
{
$message = "Salom dunyo";
return view('home', compact('message'));
}
}
21 changes: 21 additions & 0 deletions controllers/TestController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Controllers;

use Esoftuz\Framework\Controller;
use Esoftuz\Framework\Request;

class TestController extends Controller
{
public function test(Request $request)
{
$data = $request->all();

dd($data, "test");
}

public function console($args)
{
dd($args);
}
}
13 changes: 13 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require __DIR__ . '/../vendor/autoload.php';

use Esoftuz\Framework\App;
use Esoftuz\Framework\Exceptions\HttpNotFoundException;

try {
$app = new App(__DIR__);
$app->run();
} catch (HttpNotFoundException|Exception|Error|Throwable $e) {
echo abort($e->getCode(), $e->getMessage());
}
6 changes: 6 additions & 0 deletions routes/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

use Esoftuz\Framework\Router\Console\Router;
use Controllers\TestController;

Router::add('test', [TestController::class, 'console']);
8 changes: 8 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use Esoftuz\Framework\Router\Web\Router;
use Controllers\HomeController;
use Controllers\TestController;

Router::add('', [HomeController::class, 'index']);
Router::add('test', [TestController::class, 'test']);
16 changes: 16 additions & 0 deletions run
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env php
<?php

require __DIR__ . '/vendor/autoload.php';

use Esoftuz\Framework\App;
use Esoftuz\Framework\Exceptions\CommandNotFoundException;

$args = get_args();

try {
$app = new App(__DIR__);
$app->handle($args);
} catch (CommandNotFoundException $e) {
echo abort($e->getCode(), $e->getMessage());
}
13 changes: 13 additions & 0 deletions views/error.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
{{ message }}
</body>
</html>
13 changes: 13 additions & 0 deletions views/home.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
{{ message }}
</body>
</html>

0 comments on commit 8b21bef

Please sign in to comment.