1. Go to this page and download the library: Download szagot/helper 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/ */
szagot / helper example snippets
$conn = new Connection(
'banco',
'localhost',
'root',
'senha'
);
Query::setConn($conn);
$search = Query::exec(
'SELECT * FROM tabela WHERE name LIKE :name',
[
'name' => "%{$name}%",
],
MinhaClassePersonalizada::class
)
use Szagot\Helper\Server\Output;
// Saída com sucesso
Output:success($arrayDeSaida);
// Erro
Output::error('Deu ruim');
// Saída com sucesso
Output:success($arrayDeSaida, Output::POST_SUCCESS);
// Erro
Output::error('Deu ruim', Output::ERROR_NOT_FOUND);
use Szagot\Helper\Server\Uri;
use Szagot\Helper\Server\Models\Parameter;
$uri = Uri::newInstance();
// IP de quem fez a requisição
$requestIp = $uri->getRequestIp();
// Cabeçalhos da requisição recebida
$headers = getHeaders()
// Método (GET, POST, PUT, PATCH, DELETE, OPTION)
$method = $uri->getMethod();
// URL completa da requisição. Exemplo: "http://localhost:8080/pagina/opcao/detalhe"
$url = $uri->getUrl();
// String da Uri. Exemplo: "pagina/opcao/detalhe"
$uri = $uri->getTextUri();
// Primeira posição da Uri. Exemplo: "pagina"
$page = $uri->getUri(0);
// Arquivo de name "file" enviado
$file = $uri->getFile('file');
// Todos os arquivos enviados
$files = $uri->getFiles();
// Pegando parâmetros
$name = $uri->getParameter('name');
// Validando se o parâmetro "isGamer" foi informado na requisição
if($uri->parameterExists('isGamer')){
$isGamer = $uri->getParameter('isGamer', Parameter::FILTER_BOOL);
}