Crea rutas en php de la forma mas fácil posible.

Overview

SimpleRouter-php

Te permitirá crear un routing de la forma mas fácil posible, recibiendo todo lo enviado por un usuario a través de un callback.

Primero necesitas redireccionar cualquier petición con nuestro archivo de configuración .htaccess de ejemplo:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

Importa la libreria.

  require "./PhpRouter.php";

Crea una nueva instancia de la clase

  $api = new PhpRouter();

Ahora puedes usar la api, llamando a la variable donde guardaste la instancia y usar uno de sus metodos:

post, get, put, delete.

Si usas un servidor local necesitas asignar toda la ruta seguido de lo que necesitas.

desde xampp ignorando htdocs, desde wampp ignorando www, desde laragon ignorando www

teniendo el archivo principal dentro de una carpeta dentro de htdocs.

    //C:\xampp\htdocs\Prueba\ -> /Prueba/ejemplo
    //C:\wampp\www\Prueba\ -> /Prueba/ejemplo
    //C:\laragon\www\Prueba\ -> /Prueba/ejemplo

    $api->post("/Prueba/ejemplo/{numero}", function($req){
        echo json_encode($req);
    });

Al final de tu aplicación necesitas usar este metodo para la verificación de la utilización de alguna ruta.

     $api->start();

Codigo de ejemplo:

  <?php
    require "./PhpRouter.php";
    header("Content-Type: application/json");

    $api = new PhpRouter();
    $api->post("/Prueba/ejemplo/{numero}", function($req){
        echo json_encode($req);
    });

    $api->start();

Respuesta en la variable $req image

You might also like...
A PHP 5.3+ and PHP 7.3 framework for OpenGraph Protocol

Opengraph Test with Atoum cd Opengraph/ curl -s https://getcomposer.org/installer | php php composer.phar install --dev ./vendor/atoum/atoum/bin/atoum

A status monitor for Elite Dangerous, written in PHP. Designed for 1080p screens in the four-panel-view in panel.php, and for 7 inch screens with a resolution of 1024x600 connected to a Raspberry Pi.

EDStatusPanel A status monitor for Elite Dangerous, written in PHP. Designed for 1080p screens in the four-panel-view in panel.php, and for 7 inch scr

🐘 A probe program for PHP environment (一款精美的 PHP 探針, 又名X探針、劉海探針)

Simplified Chinese | 简体中文 Traditional Chinese(Taiwan) | 正體中文(臺灣) Traditional Chinese(Hong Kong) | 正體中文(香港) Japanese | 日本語 😎 X Prober This is a probe

PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

PHP generics written in PHP

PHP generics written in PHP Require PHP = 7.4 Composer (PSR-4 Autoload) Table of contents How it works Quick start Example Features Tests How it work

PHP exercises from my course at ETEC and some of my own play-around with PHP

etec-php-exercises PHP exercises from my course at ETEC and some of my own play-around with PHP Translations: Português (BR) Projects Project Descript

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

php-echarts is a php library for the echarts 5.0.

php-echarts 一款支持Apache EChart5.0+图表的php开发库 优先ThinkPHP5/6的开发及测试。 Apache EChart5.0已经最新发布,在视觉效果、动画效果和大数据展示方面已经远超之前的版本; 故不考虑EChart5.0之前版本的兼容问题;建议直接尝试5.0+

Minimalist PHP frame for Core-Library, for Developing PHP application that gives you the full control of your application.

LazyPHP lightweight Pre-Made Frame for Core-library Install Run the below command in your terminal $ composer create-project ryzen/lazyphp my-first-pr

Releases(v7.3.1)
  • v7.3.1(Nov 1, 2022)

  • v7.3.0(Oct 30, 2022)

    The order of files now is

    
    {
            "imagenes" : {
                "0" : {
                    "name" : "imagen1",
                    "url" : "http://www.imagen1.com",
                    "size" : "100x100"
                },
                "1" : {
                    "name" : "imagen2",
                    "url" : "http://www.imagen2.com",
                    "size" : "200x200"
                },
                "2" : {
                    "name" : "imagen3",
                    "url" : "http://www.imagen3.com",
                    "size" : "300x300"
                }
            }
        }    
    
    Source code(tar.gz)
    Source code(zip)
  • v7.2.1(Sep 14, 2022)

  • v7.2.0(Jul 28, 2022)

  • v7.1.0(May 24, 2022)

  • v7.0.2(Mar 30, 2022)

  • v7.0.1(Mar 30, 2022)

  • v7.0(Mar 30, 2022)

    Added: $api->patch($root, $callback);

    It not create new instance of class, now use same when you use $res->status();

    Now u can make this for allow some domains, methods and headers: $router->cors( ["easyprojects.tech", "google.com"], ["POST", "PUT", "DELETE", "GET"], ["User-Agent"] );

    Source code(tar.gz)
    Source code(zip)
  • v6.0(Dec 19, 2021)

    Now you can use params, headers, files and body as Object.

    Example: If you need to use one param from root "/user/update/{idUser}" then you need use $req->params->idUser.

    Source code(tar.gz)
    Source code(zip)
  • v5.2(Dec 18, 2021)

  • v5.1(Dec 18, 2021)

    English

    In the previous version, all the routes were verified in each execution, this prevented freeing a process when accessing a route, in this new version a correction has been integrated that helps to free that space when the route is valid, the only one The way you can free that space is by using the function of our Response class, after this the execution of the application will end.

    Now you can also enable "Cors" from the library for external use from another domain through ajax (Fetch, XMLHttpRequest, HttpReques [Angular]).

    By default it enables requests from any host, this is not necessary when having the frontend in the same domain or subdomain. Then you can delete it by uploading it to your server.

    Español

    En la anterior versión se verificaban todas las rutas en cada ejecución, esto impedía liberar un proceso al acceder a una ruta, en esta nueva versión se ha integrado una corrección que ayudará a liberar ese espacio en el momento que la ruta sea valida, la única forma en que puedes liberar ese espacio es usando la función de nuestra clase Response, luego de esto se finalizará la ejecución de la aplicación.

    Ahora también puedes habilitar "Cors" desde la librería para el uso externo desde otro dominio através de ajax(Fetch, XMLHttpRequest, HttpReques[Angular]).

    Por defecto habilita peticiones desde cualquier host, esto no es necesario al tener el frontend en el mismo dominio o subdominio. Entonces puedes borrarlo al subirlo a tu servidor.

      $api->cors();
    
    Source code(tar.gz)
    Source code(zip)
  • v5.0(Dec 9, 2021)

  • v4.2(Dec 7, 2021)

  • v4.1(Dec 7, 2021)

  • v4.0(Dec 7, 2021)

PHP 7+ Payment processing library. It offers everything you need to work with payments: Credit card & offsite purchasing, subscriptions, payouts etc. - provided by Forma-Pro

Supporting Payum Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our

Payum 1.7k Dec 27, 2022
Livro de introdução ao PHP orientado a objetos com MVC de forma prática

phpoo-livro Livro de introdução ao PHP orientado a objetos usando MVC com rotas. Porque de forma prática, por conta da criação, passo a passo, de um a

Ribamar FS 8 Dec 24, 2022
Jéssica Paula 7 Aug 12, 2022
📁 As Sessões são uma forma simples de armazenar dados para usuários, ficando mais confiável em manipular dados importantes

?? As Sessões são uma forma simples de armazenar dados para usuários, ficando mais confiável em manipular dados importantes

Gustavo de Oliveira 4 Jan 25, 2022
The Current US Version of PHP-Nuke Evolution Xtreme v3.0.1b-beta often known as Nuke-Evolution Xtreme. This is a hardened version of PHP-Nuke and is secure and safe. We are currently porting Xtreme over to PHP 8.0.3

2021 Nightly Builds Repository PHP-Nuke Evolution Xtreme Developers TheGhost - Ernest Allen Buffington (Lead Developer) SeaBeast08 - Sebastian Scott B

Ernest Buffington 7 Aug 28, 2022
A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

null 272 Dec 22, 2022
PHP Meminfo is a PHP extension that gives you insights on the PHP memory content

MEMINFO PHP Meminfo is a PHP extension that gives you insights on the PHP memory content. Its main goal is to help you understand memory leaks: by loo

Benoit Jacquemont 994 Dec 29, 2022
A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

null 258 Sep 15, 2022
A multithreaded application server for PHP, written in PHP.

appserver.io, a PHP application server This is the main repository for the appserver.io project. What is appserver.io appserver.io is a multithreaded

appserver.io 951 Dec 25, 2022
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP

Lodash-PHP Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects. Lodash-PHP tr

Lodash PHP 474 Dec 31, 2022