PHP code example of analistics / web-tools

1. Go to this page and download the library: Download analistics/web-tools 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/ */

    

analistics / web-tools example snippets




use WebTools\Http\Request;

Request::init();

$id   = Request::get('id');
$name = Request::get('name', 'Usuário');



use WebTools\Http\Cors;

Cors::Init();



use WebTools\Output\Json;

Json::show([
    'status' => 'success',
    'data' => ['id' => 1, 'name' => 'João']
], 200);



use WebTools\Output\Json;

Json::show(null, 404, 'Recurso não encontrado');



use WebTools\Output\Xml;

Xml::show([
    'status' => 'success',
    'data' => [
        'id' => 1,
        'name' => 'João'
    ]
], 200);



use WebTools\Output\Xml;

Xml::show(null, 400, 'Parâmetros inválidos');
xml
<response>
  <error>
    <message>Parâmetros inválidos</message>
    <code>400</code>
  </error>
</response>