javascript - Equivalent of express app.get("/:users/:names") in yaml for PHP? -


you know how in node.js/express/mongodb stacks can whole

app.get("/") {    helloworld()  }    app.get("/:users/:names") {    script()  }

is same idea app engine's app.yaml? or looking @ file in backwards way. file routing file equivalent, right?

handlers:  - url: /.*    script: helloworld.php      - url: /users/names/    script: getname.php

so if app wants grab user-253's name, select user, , query name using info grabbed request?

i use symfony read yaml files: http://symfony.com/doc/current/components/yaml/yaml_format.html

the code looks this:

$yamlfile = __dir__ . '/routes.yaml'; $routes = yaml::parse(file_get_contents($yamlfile));  // routes associative array , show urls. $handlers = $routes['handlers'];  echo 'url: ' . $handlers[0]['url'] . "\n"; echo 'script: ' . $handlers[0]['script'] . "\n"; echo "\n"; echo 'url: ' . $handlers[1]['url'] . "\n"; echo 'script: ' . $handlers[1]['script'] . "\n";  /* output:  url: /.* script: helloworld.php  url: /users/names/ script: getname.php  */ 

note: need format yaml file below or throw exception: you cannot define sequence item when in mapping.

handlers:     - url: /.*       script: helloworld.php      - url: /users/names/       script: getname.php 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -