PHP code example of davedevelopment / tinder

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

    

davedevelopment / tinder example snippets

 php


// an array called query will be GET vars
$app->get("/search", function (array $query) {
});

// an array called params will be POST vars
$app->post("/blog/posts", function (array $params) {
});

 php


$app->get("/dave", function() {
    return array(
        "rating" => rand(1,10),
    );
})
->template("dave.html.twig", function($data) {
    $data['rating'] = 10;
    return $data;
});

 php

$app->post("/users/{id}", function() { return; })
    ->redirect("/users");

 php

$app->get("/users/{id}", function($id) { })
    ->bind("get_user");

$app->post("/users/{id}", function($id) { return; })
    ->redirect("get_user", function($id) { return ["id" => $id]; });

 php

$app->post("/users/{id}", function($id) { return; })
    ->redirect(function($id) { return "/users/$id"; });

 php


$app['dispatcher']->addListenerService('some.event', array('some_service_name', 'someMethod'));
$app['dispatcher']->addSubscriberService('some_other_service', 'The\Fully\Qualified\ClassName\Of\That\Service');