bd
This commit is contained in:
parent
5ecf87df75
commit
e91e44ded9
5
.env
Normal file
5
.env
Normal file
@ -0,0 +1,5 @@
|
||||
DB_DRIVER=mysql
|
||||
DB_HOST="127.0.0.1"
|
||||
DB_NAME=forms
|
||||
DB_USER=root
|
||||
DB_PASSWORD=kali
|
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
19
bootstrap/db.php
Normal file
19
bootstrap/db.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require "vendor/autoload.php";
|
||||
|
||||
use Dotenv\Dotenv;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
$dotenv = Dotenv::createImmutable(ROOT_PATH);
|
||||
$dotenv->load();
|
||||
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection([
|
||||
"driver" => "mysql",
|
||||
"host" =>"127.0.0.1",
|
||||
"database" => "forms",
|
||||
"username" => "root",
|
||||
"password" => "kali"
|
||||
]);
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
0
checkPOST.php
Normal file → Executable file
0
checkPOST.php
Normal file → Executable file
96
compilation_cache/14/14bb04555643336484373f73ae8830b9.php
Normal file
96
compilation_cache/14/14bb04555643336484373f73ae8830b9.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Extension\SandboxExtension;
|
||||
use Twig\Markup;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/* main/index.html.twig */
|
||||
class __TwigTemplate_09ccf709a9c7f01a6f9c635608c9f350 extends Template
|
||||
{
|
||||
private $source;
|
||||
private $macros = [];
|
||||
|
||||
public function __construct(Environment $env)
|
||||
{
|
||||
parent::__construct($env);
|
||||
|
||||
$this->source = $this->getSourceContext();
|
||||
|
||||
$this->blocks = [
|
||||
'title' => [$this, 'block_title'],
|
||||
'content' => [$this, 'block_content'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function doGetParent(array $context)
|
||||
{
|
||||
// line 1
|
||||
return "layouts/simple.html.twig";
|
||||
}
|
||||
|
||||
protected function doDisplay(array $context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
$this->parent = $this->loadTemplate("layouts/simple.html.twig", "main/index.html.twig", 1);
|
||||
$this->parent->display($context, array_merge($this->blocks, $blocks));
|
||||
}
|
||||
|
||||
// line 3
|
||||
public function block_title($context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true);
|
||||
}
|
||||
|
||||
// line 5
|
||||
public function block_content($context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
// line 6
|
||||
echo " ";
|
||||
echo twig_escape_filter($this->env, $this->env->getFunction('create_form')->getCallable()(), "html", null, true);
|
||||
echo "
|
||||
";
|
||||
// line 7
|
||||
echo twig_escape_filter($this->env, ($context["content"] ?? null), "html", null, true);
|
||||
echo "
|
||||
";
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTemplateName()
|
||||
{
|
||||
return "main/index.html.twig";
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function isTraitable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array ( 63 => 7, 58 => 6, 54 => 5, 47 => 3, 36 => 1,);
|
||||
}
|
||||
|
||||
public function getSourceContext()
|
||||
{
|
||||
return new Source("", "main/index.html.twig", "/home/kali/php/untitled/views/main/index.html.twig");
|
||||
}
|
||||
}
|
101
compilation_cache/b6/b6a9b94df97efc8dc9336c36ada05909.php
Normal file
101
compilation_cache/b6/b6a9b94df97efc8dc9336c36ada05909.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Extension\SandboxExtension;
|
||||
use Twig\Markup;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/* layouts/simple.html.twig */
|
||||
class __TwigTemplate_e48551b2ca758109aa7de7556ee07a2e extends Template
|
||||
{
|
||||
private $source;
|
||||
private $macros = [];
|
||||
|
||||
public function __construct(Environment $env)
|
||||
{
|
||||
parent::__construct($env);
|
||||
|
||||
$this->source = $this->getSourceContext();
|
||||
|
||||
$this->parent = false;
|
||||
|
||||
$this->blocks = [
|
||||
'title' => [$this, 'block_title'],
|
||||
'content' => [$this, 'block_content'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function doDisplay(array $context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
// line 1
|
||||
echo "<!DOCTYPE html>
|
||||
<html lang=\"en\">
|
||||
<head>
|
||||
<meta charset=\"UTF-8\">
|
||||
<title>";
|
||||
// line 5
|
||||
$this->displayBlock('title', $context, $blocks);
|
||||
echo " </title>
|
||||
<link rel=\"stylesheet\" href=\"vendor/twbs/bootstrap/dist/css/bootstrap.css\">
|
||||
<link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" rel=\"stylesheet\"
|
||||
integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class=\"container\">
|
||||
<div class=\"row\">
|
||||
<div class=\"col-12\">
|
||||
";
|
||||
// line 15
|
||||
$this->displayBlock('content', $context, $blocks);
|
||||
// line 16
|
||||
echo " </div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>";
|
||||
}
|
||||
|
||||
// line 5
|
||||
public function block_title($context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
}
|
||||
|
||||
// line 15
|
||||
public function block_content($context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTemplateName()
|
||||
{
|
||||
return "layouts/simple.html.twig";
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array ( 76 => 15, 70 => 5, 60 => 16, 58 => 15, 45 => 5, 39 => 1,);
|
||||
}
|
||||
|
||||
public function getSourceContext()
|
||||
{
|
||||
return new Source("", "layouts/simple.html.twig", "/home/kali/php/untitled/views/layouts/simple.html.twig");
|
||||
}
|
||||
}
|
5
composer.json
Normal file → Executable file
5
composer.json
Normal file → Executable file
@ -14,6 +14,9 @@
|
||||
"require": {
|
||||
"twbs/bootstrap": "5.0.2",
|
||||
"itguild/php-cg-select-v2": "^0.1.0",
|
||||
"craft-group/phroute": "^2.1"
|
||||
"craft-group/phroute": "^2.1",
|
||||
"twig/twig": "^3.0",
|
||||
"illuminate/database": "^11.0",
|
||||
"vlucas/phpdotenv": "^5.6"
|
||||
}
|
||||
}
|
||||
|
1797
composer.lock
generated
Normal file → Executable file
1797
composer.lock
generated
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
11
console.php
Normal file
11
console.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use itguild\forms\migrations\UserMigration;
|
||||
|
||||
const ROOT_PATH = __DIR__;
|
||||
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
require_once "bootstrap/db.php";
|
||||
|
||||
UserMigration::up();
|
0
example.php
Normal file → Executable file
0
example.php
Normal file → Executable file
0
example_json.php
Normal file → Executable file
0
example_json.php
Normal file → Executable file
14
index.php
Normal file → Executable file
14
index.php
Normal file → Executable file
@ -2,18 +2,26 @@
|
||||
ini_set("display_errors", 1);
|
||||
error_reporting(-1);
|
||||
|
||||
const ROOT_PATH = __DIR__;
|
||||
const VIEW_PATH = __DIR__ . "/views";
|
||||
const VIEW_CACHE_PATH = __DIR__ . "/compilation_cache";
|
||||
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
require_once "bootstrap/db.php";
|
||||
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
$router = new RouteCollector();
|
||||
|
||||
$router->get('/', [\itguild\forms\app\controllers\Main::class, 'indexAction']);
|
||||
$router->get('/example', [\itguild\forms\app\controllers\Main::class, 'exampleAction']);
|
||||
|
||||
$router->get('/', [\itguild\forms\app\controllers\MainController::class, 'indexAction']);
|
||||
$router->get('/example', [\itguild\forms\app\controllers\MainController::class, 'exampleAction']);
|
||||
$router->get('/create-user', [\itguild\forms\app\controllers\UserController::class, 'createUserAction']);
|
||||
$router->get('/get-user/{id}', [\itguild\forms\app\controllers\UserController::class, 'getUserAction']);
|
||||
$dispatcher = new Phroute\Phroute\Dispatcher($router->getData());
|
||||
|
||||
$response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
||||
|
||||
|
||||
// Print out the value returned from the dispatched function
|
||||
echo $response;
|
0
old_index.php
Normal file → Executable file
0
old_index.php
Normal file → Executable file
2
routing.php
Normal file → Executable file
2
routing.php
Normal file → Executable file
@ -8,4 +8,4 @@ use Phroute\Phroute\RouteCollector;
|
||||
|
||||
$router = new RouteCollector();
|
||||
|
||||
$router->get('/', [\itguild\forms\app\controllers\Main::class, 'indexAction']);
|
||||
$router->get('/', [\itguild\forms\app\controllers\MainController::class, 'indexAction']);
|
||||
|
0
src/ActiveForm.php
Normal file → Executable file
0
src/ActiveForm.php
Normal file → Executable file
0
src/Form.php
Normal file → Executable file
0
src/Form.php
Normal file → Executable file
5
src/JsonForm.php
Normal file → Executable file
5
src/JsonForm.php
Normal file → Executable file
@ -66,4 +66,9 @@ class JsonForm
|
||||
echo $this->html;
|
||||
}
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
class Main
|
||||
{
|
||||
|
||||
public function indexAction(): void
|
||||
{
|
||||
echo 123;
|
||||
}
|
||||
|
||||
public function exampleAction()
|
||||
{
|
||||
echo "example";
|
||||
}
|
||||
|
||||
}
|
30
src/app/controllers/MainController.php
Executable file
30
src/app/controllers/MainController.php
Executable file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\debug\Debug;
|
||||
use itguild\forms\JsonForm;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class MainController extends BaseController
|
||||
{
|
||||
private $html;
|
||||
|
||||
public function indexAction(): void
|
||||
{
|
||||
$this->view->addFunction(new TwigFunction("create_form", function (){
|
||||
$form = new JsonForm(file_get_contents("form.json"));
|
||||
$form->convertHTML();
|
||||
$form->render();
|
||||
}));
|
||||
|
||||
echo $this->view->render('main/index.html.twig', ['title' => 'Заголовок', 'content' => ""]);
|
||||
}
|
||||
|
||||
public function exampleAction()
|
||||
{
|
||||
echo "example";
|
||||
}
|
||||
|
||||
}
|
22
src/app/controllers/UserController.php
Normal file
22
src/app/controllers/UserController.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\app\models\User;
|
||||
use itguild\forms\debug\Debug;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
|
||||
public function createUserAction()
|
||||
{
|
||||
$user = User::Create([ 'name' => "Ahmed Khan", 'email' => "ahmed.khan@lbs.com", 'password' => password_hash("ahmedkhan",PASSWORD_BCRYPT), ]);
|
||||
}
|
||||
|
||||
public function getUserAction($id)
|
||||
{
|
||||
Debug::prn(User::find(1)->first()->email);
|
||||
}
|
||||
|
||||
}
|
17
src/app/core/BaseController.php
Normal file
17
src/app/core/BaseController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\core;
|
||||
|
||||
class BaseController
|
||||
{
|
||||
protected $view;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$loader = new \Twig\Loader\FilesystemLoader(VIEW_PATH);
|
||||
$this->view = new \Twig\Environment($loader, [
|
||||
'cache' => VIEW_CACHE_PATH,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
19
src/app/models/User.php
Normal file
19
src/app/models/User.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace itguild\forms\app\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = "user";
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password','userimage'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
}
|
0
src/builders/Builder.php
Normal file → Executable file
0
src/builders/Builder.php
Normal file → Executable file
0
src/builders/ButtonBuilder.php
Normal file → Executable file
0
src/builders/ButtonBuilder.php
Normal file → Executable file
0
src/builders/CheckBoxBuilder.php
Normal file → Executable file
0
src/builders/CheckBoxBuilder.php
Normal file → Executable file
0
src/builders/LabelBuilder.php
Normal file → Executable file
0
src/builders/LabelBuilder.php
Normal file → Executable file
0
src/builders/RadioButtonBuilder.php
Normal file → Executable file
0
src/builders/RadioButtonBuilder.php
Normal file → Executable file
0
src/builders/SelectBuilder.php
Normal file → Executable file
0
src/builders/SelectBuilder.php
Normal file → Executable file
0
src/builders/TextAreaBuilder.php
Normal file → Executable file
0
src/builders/TextAreaBuilder.php
Normal file → Executable file
0
src/builders/TextInputBuilder.php
Normal file → Executable file
0
src/builders/TextInputBuilder.php
Normal file → Executable file
0
src/debug/Debug.php
Normal file → Executable file
0
src/debug/Debug.php
Normal file → Executable file
0
src/inputs/BaseInput.php
Normal file → Executable file
0
src/inputs/BaseInput.php
Normal file → Executable file
0
src/inputs/Button.php
Normal file → Executable file
0
src/inputs/Button.php
Normal file → Executable file
0
src/inputs/Checkbox.php
Normal file → Executable file
0
src/inputs/Checkbox.php
Normal file → Executable file
0
src/inputs/Label.php
Normal file → Executable file
0
src/inputs/Label.php
Normal file → Executable file
0
src/inputs/RadioButton.php
Normal file → Executable file
0
src/inputs/RadioButton.php
Normal file → Executable file
0
src/inputs/Select.php
Normal file → Executable file
0
src/inputs/Select.php
Normal file → Executable file
0
src/inputs/TextArea.php
Normal file → Executable file
0
src/inputs/TextArea.php
Normal file → Executable file
0
src/inputs/TextInput.php
Normal file → Executable file
0
src/inputs/TextInput.php
Normal file → Executable file
0
src/mappers/JsonInputMapper.php
Normal file → Executable file
0
src/mappers/JsonInputMapper.php
Normal file → Executable file
30
src/migrations/UserMigration.php
Normal file
30
src/migrations/UserMigration.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\migrations;
|
||||
use Illuminate;
|
||||
|
||||
class UserMigration
|
||||
{
|
||||
|
||||
public static function up(): void
|
||||
{
|
||||
|
||||
Illuminate\Database\Capsule\Manager::schema()->create("user", function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('userimage')->nullable();
|
||||
$table->string('api_key')->nullable()->unique();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static function down(): void
|
||||
{
|
||||
Illuminate\Database\Capsule\Manager::schema()->drop("user");
|
||||
}
|
||||
|
||||
}
|
0
src/templates/Simple/SimpleTemplate.php
Normal file → Executable file
0
src/templates/Simple/SimpleTemplate.php
Normal file → Executable file
0
src/templates/Template.php
Normal file → Executable file
0
src/templates/Template.php
Normal file → Executable file
0
src/templates/bootstrap5/Bootstrap5Template.php
Normal file → Executable file
0
src/templates/bootstrap5/Bootstrap5Template.php
Normal file → Executable file
0
src/traits/CreateOption.php
Normal file → Executable file
0
src/traits/CreateOption.php
Normal file → Executable file
0
src/traits/CreateParams.php
Normal file → Executable file
0
src/traits/CreateParams.php
Normal file → Executable file
22
views/layouts/simple.html.twig
Normal file
22
views/layouts/simple.html.twig
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}{% endblock %} </title>
|
||||
<link rel="stylesheet" href="vendor/twbs/bootstrap/dist/css/bootstrap.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
8
views/main/index.html.twig
Executable file
8
views/main/index.html.twig
Executable file
@ -0,0 +1,8 @@
|
||||
{% extends "layouts/simple.html.twig" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ create_form() }}
|
||||
{{ content }}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user