La pr谷sentation a pour but de revenir sur diff谷rents aspects avanc谷s de Doctrine mis en oeuvre au sein de projets Symfony 2.x/3.
Elle abordera, entre autres, les 谷l谷ments suivants :
?tendre le vocabulaire DQL (sp谷cifiquement ou 角 l'aide de bundles existants)
Utiliser les diff谷rents listeners existants (annotations, listeners, subscribers, utilisation de l'UOW de Doctrine lors d'un flush, etc.)
Cr谷er des hydrateurs sp谷cifiques ou des entit谷s partielles pour am谷liorer les performances sur certaines op谷rations.
Astuces diverses pour am谷liorer les performances (d谷sactivation des logs, etc.)
Practical JavaScript Programming - Session 3/8Wilson Su
?
JavaScript is one of the most popular skills in today*s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
※Practical JavaScript Programming§ does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You*ll learn about topics like Data Types, Functions, Events, AJAX and more.
Practical JavaScript Programming - Session 2/8Wilson Su
?
JavaScript is one of the most popular skills in today*s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
※Practical JavaScript Programming§ does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You*ll learn about topics like Data Types, Functions, Events, AJAX and more.
Practical JavaScript Programming - Session 2/8Wilson Su
?
JavaScript is one of the most popular skills in today*s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
※Practical JavaScript Programming§ does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You*ll learn about topics like Data Types, Functions, Events, AJAX and more.
Valeriy Rabievskiy leads a web studio called stfalcon.com and is an active open source developer. Doctrine 2 is separated into common, DBAL, ORM, and migrations libraries. Entities are lightweight PHP classes that store data in object properties without needing to extend a base class. The EntityManager acts as the central access point for ORM functions like updating entities and accessing repositories. ZF2 integrates with Doctrine 2 through autoloading. The console provides commands for tasks like validating the schema, generating proxies, and running migrations to update the database schema.
3. # ls
Bootstrap.php docs phpunit.xml resources runtests.sh
TestConfiguration.php.dist Zend
# cat TestConfiguration.php.dist
/**
* Zend_Db_Adapter_Sqlsrv
* Note: Make sure that you create the "test" database and set a
* username and password
*
*/
define('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED', false);
define('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME', '');
define('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME', null);
define('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD', null);
define('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE', 'test');
10. /test/tests/application/controllers# cat IndexControllerTest.php
namespace Test;
class IndexController extends ZendTestPHPUnitControllerTestCase
{
public $bootstrap = '../../bootstrap.php';
/**
* @group Bug123
* @cover IndexController::indexAction
*/
public function testIndexAction()
{
$this->dispatch('/');
$this->assertController("index");
$this->assertAction("index");
}
}
妥快扼找我把抉志忘扶我快 Controller
11. 妥快扼找我把抉志忘扶我快 Controller
class IndexController extends ZendTestPHPUnitControllerTestCase
public function testIndexAction()
$this->dispatch('/');
$this->assertController("index");
$this->assertAction("index");
$this->assertQueryContentContains('#content', 'Hello Im here');
$this->assertQueryContentContains('div.content', 'Hello Im here');
$this->assertQueryContentContains('body .content', 'Hello Im here');
$this->assertQueryCount('#categories li', 3);
<?php
class IndexController extends AbstractController
public function indexAction()
$this->view->hello = 'Im here';
12. 妥快扼找我把抉志忘扶我快 Controller::init
<?php
abstract class AbstractController extends ZendControllerAction
{
public function init()
{
$this->_helper->contextSwitch()
->addActionContext('index', array('xml', 'json'))
->setAutoJsonSerialization(true)
->initContext();
$this->view->categories = new ApplicationModelCategoryMapper();
}
}
13. 妥快扼找我把抉志忘扶我快 Controller:init
class AbstractController extends ZendTestPHPUnitControllerTestCase
public function testInitContext()
$controller = new AbstractControllerStub($this->getRequest(),
$this->getResponse());
$this->assertEquals(
$controller->getHelper('ContextSwitch')->getActionContexts('index'),
array('xml', 'json'));
public function testInitCategories()
$controller = new AbstractControllerStub($this->getRequest(),
$this->getResponse());
$this->assertType('ApplicationModelCategoryMapper',
$controller->view->categories);
14. 妥快扼找我把抉志忘扶我快 Form
<?php
namespace ApplicationForm;
class Registration extends ZendFormForm
public function init()
$this->addElement('text', 'username');
$this->addElement('text', 'password');
$this->addElement('text', 'password_retype');
public function isValid($params)
$result = parent::isValid($params);
if ($this->getValue('password')!=$this->getValue('password_retype')) {
return false;
}
return $result;
15. 妥快扼找我把抉志忘扶我快 Form
class Registration extends PHPUnit_Framework_TestCase
public function testValidate()
$form = new ApplicationFormRegistration;
$this->assertTrue($form->isValid(array(
'username' => 'test',
'password' => '123',
'password_retype' => '123',
)));
public function testValidateFail()
$form = new ApplicationFormRegistration;
$this->assertFalse($form->isValid(array(
'username' => 'test',
'password' => '123',
'password_retype' => '1234',
)));
18. 妥快扼找我把抉志忘扶我快 DbTable
class CategoriesTest extends ZendTestPHPUnitDatabaseTestCase
public function getConnection()
$application = new Application (_ENV, _PATH . '/configs/application.ini');
$application->bootstrap();
$resource = $application->getBootstrap()->getPluginResource('db');
return $this->createZendDbConnection($resource->getDbAdapter(), 'any');
public function getDataSet()
return $this->createFlatXMLDataSet(__DIR__ . '/_fixtures/categories.xml');
public function testFecthAll()
$categories = new ApplicationModelDbTableCategories($this->getAdapter());
$rowset = $categories->fetchAllOrdered();
$this->assertEquals(count($rowset), 3);
21. 妥快扼找我把抉志忘扶我快 Mapper
<?php
namespace ApplicationModel;
class XXXMapper
{
protected $_table = null;
protected $_defaultServiceName = '';
public function __construct(DbTable $table=null)
public function getTable()
public function setTable(DbTable $table)
#
}
25. 妥快扼找我把抉志忘扶我快 Mapper
class AbstractMapperTest extends PHPUnit_Framework_TestCase
public function testInit()
$mock = new AbstractMapperMockAutoload();
$this->assertType('TestServiceMock', $mock->getService());
public function testInitFail()
try {
$mock = new AbstractMapperMock();
} catch (Exception $e) {
return ;
}
$this->fail('An expected exception has not been raised.');
public function testSet()
$mock = new AbstractMapperMockAutoload();
$mock->setService(new ServiceMock());
$this->assertType('TestServiceMock', $mock->getService());