PHP code example of xdire / dude-pmvc

1. Go to this page and download the library: Download xdire/dude-pmvc 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/ */

    

xdire / dude-pmvc example snippets


App::route(ROUTE_ALL,'/',function ($req,$resp) {
    echo "Hello world";
});

namespace App\Controller;
use Xdire\Dude\Core\Face\RoutingController;
use Xdire\Dude\Server\Request;
use Xdire\Dude\Server\Response;

class ExampleController implements RoutingController
{
  public function acceptRoute(Request $request, Response $response)
  {
  	$response->send(200,"<h2>Hey Dude!</h2>Route was accepted");
  }
}


App::route(ROUTE_ALL,'/',function ($req,$resp) {
    App::routeController('ExampleController@testRoute',$req,$resp);
});

App::route(ROUTE_GET,'/',function ($req,$resp) {
    App::routeController('ExampleController@testRoute',$req,$resp);
});

App::route(ROUTE_POST,'/',function ($req,$resp) {
    App::routeController('ExampleController@testRoute',$req,$resp);
});
text
php composer.phar create-project xdire/dude-pmvc myapp
text
php composer.phar update
text
<Directory "/somepath/myapp/public">
    AllowOverride None
    Require all granted
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php
    </IfModule>
</Directory>
<VirtualHost *:80>
   ServerName someserver.domain
   DocumentRoot "/somepath/myapp/public"
</VirtualHost>
text
server {
    listen	 80;
    server_name  localhost;

	location / {
                if (!-e $request_filename) {
                    rewrite (.*)$ /index.php last;
                }
        }

	root   /somepath/myapp/public;
    index  index.php index.html index.htm;

    location ~ \.php$ {
        fastcgi_param   APPENVIRONMENT  prod;
        fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME /somepath/myapp/public$fastcgi_script_name;
        
text
ROUTE_ALL
ROUTE_GET
ROUTE_POST
ROUTE_UPD
ROUTE_DEL
ROUTE_PUT
ROUTE_OPT