PHP code example of adrotec / breeze.server.php

1. Go to this page and download the library: Download adrotec/breeze.server.php 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/ */

    

adrotec / breeze.server.php example snippets


/* @var $entityManager instanceof \Doctrine\ORM\EntityManager */
/* @var $serializer instanceof \JMS\Serializer\SerializerInterface */
/* @var $validator instanceof \Symfony\Component\Validator\Validator\ValidatorInterface */

$app = new Adrotec\BreezeJs\Framework\Application(
  $entityManager,
  $serializer,
  $validator
);

$app->addResources(array(
    'Employees' => 'EmpDirectory\Model\Employee',
    'Departments' => 'EmpDirectory\Model\Department',
    'Jobs' => 'EmpDirectory\Model\Job',
));

/* @var $request instanceof \Symfony\Component\HttpFoundation\Request */

$response = $app->handle($request);


$loader = w Adrotec\BreezeJs\Framework\StandaloneApplication();

$app->setConnection(array(
    'driver' => 'pdo_mysql',
    'host' => 'localhost',
    'dbname' => 'employees',
    'user' => 'root',
    'password' => ''
));

// configuring doctrine, serializer and validator
// using xml mappings
$app->addMapping(array(
    'namespace' => 'EmpDirectory\Model',
    'type' => 'xml',
    'extension' => '.orm.xml', // default ".dcm.xml"
    'doctrine' => __DIR__ . '/src/EmpDirectory/config/doctrine', // doctrine directory
    'serializer' => __DIR__ . '/src/EmpDirectory/config/serializer', // [optional] serializer metadata directory
    'validation' => __DIR__ . '/src/EmpDirectory/config/validation.xml', // [optional] validation file
));

// limiting the api to certain classes
$app->addResources(array(
    // Resource name => Class name
    'Employees' => 'EmpDirectory\Model\Employee',
    'Jobs' => 'EmpDirectory\Model\Job',
    'Departments' => 'EmpDirectory\Model\Department',
));

$app->build();

$app->run();