Retour d'expérience MeteorJS
Retour d'expérience sur une application mobile avec site internet, back office. Le tout utilisant la caméra, et faisant du paiement en ligne.
Formation ALG
{
"name": "moi/monexemple",
"license": "MIT",
"type": "component",
"description": "Exemple de fichier composer",
"autoload": {
"psr-0": { "Moi\\MonExemple": "" }
},
"require": {
"php": ">=5.3.3",
"guzzle/guzzle": "4.0"
},
"require-dev": {
"atoum/atoum": "~1"
}
}
{ "require": { "silex/silex": "~1.2" }, "minimum-stability": "dev" }
<?php // fichier web/demo1.php $loader = require_once __DIR__.'/../vendor/autoload.php'; // thanks to composer $app = new Silex\Application(); $app['debug'] = true; // definitions $app->get('/hello/{name}', function ($name) { return 'hello ' . $name; }) ->assert('name', '[a-z]*') ->value('name', 'world'); $app->run();
<?php // fichier web/demo1.php $loader = require_once __DIR__.'/../bootstrap.php'; $app = new Silex\Application(); $app['debug'] = true; // sample for using monolog (dont' forget to install file with composer) $app->register(new Silex\Provider\MonologServiceProvider(), array( 'monolog.logfile' => __DIR__.'/../logs/development.log', )); // definitions $app->mount('/hello', new PeaksTuto\HelloControllerProvider); $app->run();
<?php $loader = require_once __DIR__.'/vendor/autoload.php'; // add your namespaces $prefixList = require_once __DIR__.'/kernel.php'; // load your controller for each namespace loaded by kernel if (count($prefixList) > 0) { foreach ($prefixList as $prefixName => $prefixSrc) { $loader->add($prefixName, $prefixSrc); } unset($prefixName, $prefixSrc); } $app = new Silex\Application();
<?php $prefixList = array( 'PeaksTuto' => __DIR__.'/src', ); return $prefixList;
<?php namespace PeaksTuto; use Silex\Application; use Silex\ControllerProviderInterface; class HelloControllerProvider implements ControllerProviderInterface { public function connect(Application $app) { $controllers = $app['controllers_factory']; // route will depend on mount name in index file : might be /hello/{name} but may also be /whatIWant/{name} $controllers->get('/{name}', function ($name) use ($app) { $app['monolog']->addInfo(sprintf("name selected is %s", $name)); return 'hello ' . $name; }) ->assert('name', '[a-z]*') ->value('name', 'world'); return $controllers; } }
php composer.phar create-project symfony/framework-standard-edition alg_sf 2.6
php app/check.php
php console clear:cache --env=prod
php app/console generate:bundle
ALG/DemoBundle
puis modifier le routing.yml pour changer le prefix : /alg
videz votre cache ;-)
"require": {
"php": ">=5.4.0",
"rebolon/pager-bundle": "dev-master"
}
$myLogger = $this->get('logger'); //récupération du service logger
php app/console container:debug
// fichier services.xml de votre bundle
<parameters
<parameter key="rebolon_pager.pager.class">Rebolon\Bundle\Pager\Pager</parameter>
</parameters>
<services>
<service id="rebolon_pager.pager" class="%rebolon_pager.pager.class%">
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
<call method="setSuffixName">
<argument>%rebolon_pager.suffixname%</argument>
</call>
...
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(... ,
new Rebolon\Bundle\Pager\RebolonPagerBundle(),
alg_tuto:
resource: "@AlgTutoBundle/Controller/"
type: annotation
prefix: /alg
class DemoController extends Controller
{
/**
* @Route("/{name}", name="_demo", requirements={"id" = "*"}, defaults={"name" = "world"})
* @Method({"GET", "POST"})
*/
public function indexAction($name)
{
....
$dispatcher = new EventDispatcher();
$dispatcher->addListener('event.name', callable[, priority]);
$dispatcher->dispatch('event.name');
$stopwatch = new Stopwatch();
$stopwatch->start('eventName');
$event = $stopwatch->stop('eventName');
$event->getDuration();
$event->getMemory();
... Et plein d'autres choses
$process = new Process('ls -lsa');
$process->setTimeout(3600);
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
print $process->getOutput();
$finder = new Finder();
$finder->files()->in('src/Symfony/*/*/Resources')
->name('smiley*')->size('< 100K')->date('since 1 hour ago');
foreach ($finder->files() as $file) {
print $file->getFilename()."\n"; // SplFileInfo $file
}
// vous avez besoin d'une classe
class MyShellCommand extends Command
// et de 2 méthodes protected function configure() // pour setter les parametres, et le help protected function execute(InputInterface $input, OutputInterface $output)
By Retour d'expérience MeteorJS
Quick learning of Symfony
Retour d'expérience sur une application mobile avec site internet, back office. Le tout utilisant la caméra, et faisant du paiement en ligne.