1. Go to this page and download the library: Download hardjunior/mini-frame library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$addresses = new Address();
$address = $addresses->findById(22);
//get user data to this->user->[all data]
$address->user();
var_dump($address);
use Example\Models\User;
$model = new User();
$count = $model->find()->count();
use Example\Models\User;
$user = new User();
$user->first_name = "Ivamar";
$user->last_name = "Júnior";
$userId = $user->save();
use Example\Models\User;
$user = (new User())->findById(2);
$user->first_name = "Ivamar";
$userId = $user->save();
use Example\Models\User;
$user = (new User())->findById(2);
$user->destroy();
use Example\Models\User;
$user = (new User())->findById(2);
if($user->fail()){
echo $user->fail()->getMessage();
}
class User{
//...
public function fullName(): string
{
return "{$this->first_name} {$this->last_name}";
}
public function document(): string
{
return "Restrict";
}
}
echo $this->full_name; //Ivamar júnior
echo $this->document; //Restrict
= new \HardJunior\Optimizer\Optimizer();
echo $op->optimize(
"Optimizer Happy and @hardjunior",
"Is a compact and easy-to-use tag creator to optimize your site",
"https://hardjunior.ddns.net/hardjunior/optimizer/example/",
"https://hardjunior.ddns.net/uploads/images/2017/11/curso-de-html5-preparando-ambiente-de-trabalho-aula-02-1511276983.jpg"
)->render();
= new \HardJunior\Optimizer\Optimizer();
echo $op->publisher(
"Ivamar",
"hardjunior"
)->render();
= new \HardJunior\Optimizer\Optimizer();
echo $op->twitterCard(
"@hardjunior",
"@hardjunior",
"hardjunior.ddns.net",
"summary_large_image"
)->render();
= new \HardJunior\Optimizer\Optimizer();
echo $op->openGraph(
"hardjunior",
"pt_BR",
"article"
)->render();
hardjunior\Router\Router;
$router = new Router("https://www.youdomain.com");
/**
* routes
* The controller must be in the namespace Test\Controller
* this produces routes for route, route/$id, route/{$id}/profile, etc.
*/
$router->namespace("Test");
$router->get("/route", "Controller:method");
$router->post("/route/{id}", "Controller:method");
$router->put("/route/{id}/profile", "Controller:method");
$router->patch("/route/{id}/profile/{photo}", "Controller:method");
$router->delete("/route/{id}", "Controller:method");
/**
* group by routes and namespace
* this produces routes for /admin/route and /admin/route/$id
* The controller must be in the namespace Dash\Controller
*/
$router->group("admin")->namespace("Dash");
$router->get("/route", "Controller:method");
$router->post("/route/{id}", "Controller:method");
/**
* Group Error
* This monitors all Router errors. Are they: 400 Bad Request, 404 Not Found, 405 Method Not Allowed and 501 Not Implemented
*/
$router->group("error")->namespace("Test");
$router->get("/{errcode}", "Controller:notFound");
/**
* This method executes the routes
*/
$router->dispatch();
/*
* Redirect all errors
*/
if ($router->error()) {
$router->redirect("/error/{$router->error()}");
}
hardjunior\Router\Router;
$router = new Router("https://www.youdomain.com");
/**
* routes
* The controller must be in the namespace Test\Controller
*/
$router->namespace("Test")->group("name");
$router->get("/", "Name:home", "name.home");
$router->get("/hello", "Name:hello", "name.hello");
$router->get("/redirect", "Name:redirect", "name.redirect");
/**
* This method executes the routes
*/
$router->dispatch();
/*
* Redirect all errors
*/
if ($router->error()) {
$router->redirect("name.hello");
}
class Name
{
public function __construct($router)
{
$this->router = $router;
}
public function home(): void
{
echo "<h1>Home</h1>";
echo "<p>", $this->router->route("name.home"), "</p>";
echo "<p>", $this->router->route("name.hello"), "</p>";
echo "<p>", $this->router->route("name.redirect"), "</p>";
}
public function redirect(): void
{
$this->router->redirect("name.hello");
}
}