Software development is riddled with explicit and implicit costs. Every decision you make has a cost attached to it. When you're writing code, you're making an investment, the size of which will for a long time define the costs of your future growth. Making right decision about these investments is very tricky and the cost of wrong decisions might be crippling for both business and teams that support it.
Extreme Programming and Test Driven Development in particular are practices that are aiming at supporting development effort by making it easier to introduce change. That said, sometimes those tools can become a problem of its own when applied in the wrong way or for the wrong context. Understanding software cost forces is a very important skill of successful teams and something that helps understand how to apply XP and TDD in different contexts.
Silex is a brand new PHP 5.3 micro framework built on top of the Symfony2 de decoupled components. In this session, we will discover how to build and deploy powerful REST web services with such a micro framework and its embedded tools.
The first part of this talk will introduce the basics of the REST architecture. We fill focus on the main concepts of REST like HTTP methods, URIs and open formats like XML and JSON.
Then, we will discover how to deploy REST services using most of interesting Silex tools like database abstraction layer, template engine and input validation. We will also look at unit and functional testing frameworks with PHPUnit and HTTP caching with Edge Side Includes and Varnish support to improve performances.
Software development is riddled with explicit and implicit costs. Every decision you make has a cost attached to it. When you're writing code, you're making an investment, the size of which will for a long time define the costs of your future growth. In this talk you will learn how to see, understand and game some of these forces in your favour.
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
Cette conférence présente deux grands motifs de conception : l'observateur et l'injection de dépendance. Ce sujet allie à la fois théorie et pratique. Le composant autonome EventDispatcher de Symfony ainsi que le conteneur d'injection de dépendance Pimple sont mis à l'honneur avec des exemples pratiques d'usage. Ces cas pratiques combinent du code de l'ORM Propel ainsi que le composant autonome Zend\Search\Lucene du Zend Framework 2
Have you ever wondered how all this CQRS / ES concepts could be applied to a PHP project? Let's take a look at some code of our last project: a warehouse management system.
This talk will show how we understand DDD and how we apply it at Ulabox, what changes in application's architecture and code when we apply CQRS and how to deal with event sourcing, when there're no persisted entities, only events that generate projections used in the read model.
Speaker: Manel Sellés (@manelselles), software engineer, DDD-TDD fan and Symfony Expert Certified by Sensiolabs. Currently developing enterprise logistics software at Ulabox.com
This session introduces most well known design patterns to build PHP classes and objects that need to store and fetch data from a relational databases. The session will describe the difference between of the Active Record, the Table and Row Data Gateway and the Data Mapper pattern. We will also examine some technical advantages and drawbacks of these implementations. This talk will expose some of the best PHP tools, which ease database interactions and are built on top of these patterns.
Software development is riddled with explicit and implicit costs. Every decision you make has a cost attached to it. When you're writing code, you're making an investment, the size of which will for a long time define the costs of your future growth. Making right decision about these investments is very tricky and the cost of wrong decisions might be crippling for both business and teams that support it.
Extreme Programming and Test Driven Development in particular are practices that are aiming at supporting development effort by making it easier to introduce change. That said, sometimes those tools can become a problem of its own when applied in the wrong way or for the wrong context. Understanding software cost forces is a very important skill of successful teams and something that helps understand how to apply XP and TDD in different contexts.
Silex is a brand new PHP 5.3 micro framework built on top of the Symfony2 de decoupled components. In this session, we will discover how to build and deploy powerful REST web services with such a micro framework and its embedded tools.
The first part of this talk will introduce the basics of the REST architecture. We fill focus on the main concepts of REST like HTTP methods, URIs and open formats like XML and JSON.
Then, we will discover how to deploy REST services using most of interesting Silex tools like database abstraction layer, template engine and input validation. We will also look at unit and functional testing frameworks with PHPUnit and HTTP caching with Edge Side Includes and Varnish support to improve performances.
Software development is riddled with explicit and implicit costs. Every decision you make has a cost attached to it. When you're writing code, you're making an investment, the size of which will for a long time define the costs of your future growth. In this talk you will learn how to see, understand and game some of these forces in your favour.
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
Cette conférence présente deux grands motifs de conception : l'observateur et l'injection de dépendance. Ce sujet allie à la fois théorie et pratique. Le composant autonome EventDispatcher de Symfony ainsi que le conteneur d'injection de dépendance Pimple sont mis à l'honneur avec des exemples pratiques d'usage. Ces cas pratiques combinent du code de l'ORM Propel ainsi que le composant autonome Zend\Search\Lucene du Zend Framework 2
Have you ever wondered how all this CQRS / ES concepts could be applied to a PHP project? Let's take a look at some code of our last project: a warehouse management system.
This talk will show how we understand DDD and how we apply it at Ulabox, what changes in application's architecture and code when we apply CQRS and how to deal with event sourcing, when there're no persisted entities, only events that generate projections used in the read model.
Speaker: Manel Sellés (@manelselles), software engineer, DDD-TDD fan and Symfony Expert Certified by Sensiolabs. Currently developing enterprise logistics software at Ulabox.com
This session introduces most well known design patterns to build PHP classes and objects that need to store and fetch data from a relational databases. The session will describe the difference between of the Active Record, the Table and Row Data Gateway and the Data Mapper pattern. We will also examine some technical advantages and drawbacks of these implementations. This talk will expose some of the best PHP tools, which ease database interactions and are built on top of these patterns.
Persistence is one of the most important part in a PHP project. Persisting data to a database came with PHP/FI and its MySQL support. From native extensions and PHP4 database abstraction libraries to PDO and modern ORM frameworks, you will (re)discover how persistence has evolved during the last decade. This talk will also introduce the future of data persistence with the growing success of alternative storage engines.
How do you create applications with an incredible level of extendability without losing readability in the process? What if there's a way to separate concerns not only on the code, but on the service definition level? This talk will explore structural and behavioural patterns and ways to enrich them through tricks of powerful dependency injection containers such as Symfony2 DIC component.
Models and Service Layers, Hemoglobin and HobgoblinsRoss Tuck
As presented at ZendCon 2014, AmsterdamPHP, PHPBenelux 2014, Sweetlake PHP and PHP Northwest 2013, an overview of some different patterns for integrating and managing logic throughout your application.
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
Dependency Injection (DI) is a fantastic technique, but what if you what to use dependency injection in your legacy application. Fear not! As someone who as done this very thing, I will show how you can successful and incrementally add DI to any application. I will present a number of recipes and solutions to common problems and give a tour of the various PHP DI projects and how they can help.
As presented at Dutch PHP Conference 2015, an introduction to command buses, how to implement your own in PHP and why they're both useful but unimportant.
Un gioco in cui vincono tutti o due piccioni con una fava ;)
Lavorare rivolti alla creazione di valore per il cliente e da questo ottenere una libreria quasi pronta per essere pubblicata
The IoC Hydra - Dutch PHP Conference 2016Kacper Gunia
Slides from my talk presented during Dutch PHP Conference in Amsterdam - 25 June 2016
More Domain-Driven Design related content at: https://domaincentric.net/
Introduction to CQRS and Event SourcingSamuel ROZE
Event Sourcing is the idea that every state of your application can be represented by a sequence of events. Using these two principles as the heart of a system or an application is quite common but can be challenging if we don’t use the right tools or architecture.
Closing keynote, as presented at Codemotion 2014, LaraconEU 2014, Redevelop 2014, CodeConnexx 2013 and PHP North East 2014.
This presentation makes a reference to a reading list I received. For those interested, the release consists of most of the general classics, such as Gang Of Four "Design Patterns", The Pragmatic Programmer, Structure and Interpretation of Computer Programs, Domain Driven Design and a few others. The actual list remains tucked away in a box somewhere.
Symfony World - Symfony components and design patternsŁukasz Chruściel
There are so many Symfony components already, and they have some pretty neat perks. But have you seen them in action?
Design patterns are not a silver bullet. They will never resolve your problem on their own. On the other hand, design patterns provide a common ground for developers without going into details and could be used as building bricks to solve some more advanced problems.
During my presentation, I will take a closer look and explain the appliance of selected design patterns. What is more, I will take advantage of the Symfony ecosystem to implement them with ease.
I will do the presentation on sample code that developers will understand at all levels of expertise.
Persistence is one of the most important part in a PHP project. Persisting data to a database came with PHP/FI and its MySQL support. From native extensions and PHP4 database abstraction libraries to PDO and modern ORM frameworks, you will (re)discover how persistence has evolved during the last decade. This talk will also introduce the future of data persistence with the growing success of alternative storage engines.
How do you create applications with an incredible level of extendability without losing readability in the process? What if there's a way to separate concerns not only on the code, but on the service definition level? This talk will explore structural and behavioural patterns and ways to enrich them through tricks of powerful dependency injection containers such as Symfony2 DIC component.
Models and Service Layers, Hemoglobin and HobgoblinsRoss Tuck
As presented at ZendCon 2014, AmsterdamPHP, PHPBenelux 2014, Sweetlake PHP and PHP Northwest 2013, an overview of some different patterns for integrating and managing logic throughout your application.
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
Dependency Injection (DI) is a fantastic technique, but what if you what to use dependency injection in your legacy application. Fear not! As someone who as done this very thing, I will show how you can successful and incrementally add DI to any application. I will present a number of recipes and solutions to common problems and give a tour of the various PHP DI projects and how they can help.
As presented at Dutch PHP Conference 2015, an introduction to command buses, how to implement your own in PHP and why they're both useful but unimportant.
Un gioco in cui vincono tutti o due piccioni con una fava ;)
Lavorare rivolti alla creazione di valore per il cliente e da questo ottenere una libreria quasi pronta per essere pubblicata
The IoC Hydra - Dutch PHP Conference 2016Kacper Gunia
Slides from my talk presented during Dutch PHP Conference in Amsterdam - 25 June 2016
More Domain-Driven Design related content at: https://domaincentric.net/
Introduction to CQRS and Event SourcingSamuel ROZE
Event Sourcing is the idea that every state of your application can be represented by a sequence of events. Using these two principles as the heart of a system or an application is quite common but can be challenging if we don’t use the right tools or architecture.
Closing keynote, as presented at Codemotion 2014, LaraconEU 2014, Redevelop 2014, CodeConnexx 2013 and PHP North East 2014.
This presentation makes a reference to a reading list I received. For those interested, the release consists of most of the general classics, such as Gang Of Four "Design Patterns", The Pragmatic Programmer, Structure and Interpretation of Computer Programs, Domain Driven Design and a few others. The actual list remains tucked away in a box somewhere.
Symfony World - Symfony components and design patternsŁukasz Chruściel
There are so many Symfony components already, and they have some pretty neat perks. But have you seen them in action?
Design patterns are not a silver bullet. They will never resolve your problem on their own. On the other hand, design patterns provide a common ground for developers without going into details and could be used as building bricks to solve some more advanced problems.
During my presentation, I will take a closer look and explain the appliance of selected design patterns. What is more, I will take advantage of the Symfony ecosystem to implement them with ease.
I will do the presentation on sample code that developers will understand at all levels of expertise.
“Overall sentiments in the markets are very edgy and such occasional setbacks will continue to happen till a more reassuring feeling settles down among investors,” said Jagannadham Thunuguntla, head of the capital markets arm and director of India’s fourth largest share brokerage firm, the Delhi-based SMC Group.
The REST API is an awesome plugin to expose your data from the WordPress core. But … the standard implementation might not fit your specific case.
Just like the WordPress core, you'll be able to extend it to your specific needs. I'll show you how to handle authentication, introduce caching strategies, alter custom post types, or even change the default way of communication altogether.
Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost 500 million times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.
In 2010, I told everyone how to start unit testing Zend Framework applications. In 2011, let’s take this a step further by testing services, work flows and performance. Looking to raise the bar on quality? Let this talk be the push you need to improve your Zend Framework projects.
The REST API is an awesome plugin to expose your data from the WordPress core. But … the standard implementation might not fit your specific case.
Just like the WordPress core, you'll be able to extend it to your specific needs. I'll show you how to handle authentication, introduce caching strategies, alter custom post types, or even change the default way of communication altogether.
Everyone talks about raising the bar on the quality of code, but it’s hard to implement when you have no clue where to start. This talk is geared toward all levels of developers, and will teach you how to improve by using the right tools effectively – a must-attend for any PHP developer who wants to scale up their quality.
Michelangelo will tell us about Quality Assurance for PHP in general and show how different QA-related actions can be performed using PhpStorm IDE. The webinar will cover topics including:
Revision control
Syntax checking
Code documentation
Unit Testing with PHPUnit
Measuring code health with a variety of tools
Profiling and debugging with Xdebug
Automation with Phing
Team work and more.
n 2010, I told everyone how to start unit testing Zend Framework applications. In 2011, let’s take this a step further by testing services, work flows and performance. Looking to raise the bar on quality? Let this talk be the push you need to improve your Zend Framework projects.
iPhone applications can often benefit by talking to a web service to synchronize data or share information with a community. Ruby on Rails, with its RESTful conventions, is an ideal backend for iPhone applications. In this session you'll learn how to use ObjectiveResource in an iPhone application to interact with a RESTful web service implemented in Rails. This session isn't about how to build web applications that are served up on the iPhone. It's about how to build iPhone applications with a native look and feel that happen to talk to Rails applications under the hood. The upshot is a user experience that transcends the device.
Start safeguarding personal information of your users at the earliest beginning in a project and make it default.
In this talk I will go over the concepts of privacy by design and default where I will go deeper into the why and how of safeguarding your user's personal information.
When we first started out with Azure, we created VM’s to run our web applications and backend services. Afterwards we moved our web application logic into App Services while using native Azure Services for our backend requirements. With containers we could isolate our individual web application components even further and allowed us to go full DevOps. Now Azure Functions allows us to remove a complete application stack allowing us to focus purely on functionality.
In this talk I go over the several phases we went through getting our application from bare metal into the cloud and how we now leverage Azure Functions to achieve higher throughput and faster delivery times while reducing the complexity of the web application and costs.
We now have to obey the law and comply with GDPR, ensuring people's data are securely stored, we track who has access to it and if the client requests to review, update or remove their data, we should do so in an automated fashion. But, are you there yet? Chances are, there's still a long way to go.
In this talk I will address some of the challenges we solved in greenfield projects as well in old, legacy applications. We introduced "privacy by design" as just another "by design" mantra we already had build in our workflow and as we worked on the project, we applied it everywhere when we saw user data (personal or not) was processed. This ensured that all data was handled and treated the same way and allowed the business to reorient themselves again to be creative in approaching their customers.
In 2009 Patrick Dubois coined the term "DevOps" when he organised the first "DevOpsDays" In Ghent, Belgium. Since then the term has become a term to explain the collaboration between all organisational stakeholders in IT projects (developers, operations, QA, marketing, security, legal, …) to deliver high quality, reliable solutions where issues are tackled early on in the value stream.
But reality shows that many businesses that implement "DevOps" are actually talking about a collaboration between development, QA and operations (DQO). Solutions are being provided but lack the security and/or legal regulations causing hard-to-fix problems in production environments.
In this talk I will explain how the original idea of Patrick to include all stakeholders got reduced to development, QA and operations and why it's so difficult to apply security or compliance improvements in this model. I will also talk about ways to make the DQO model welcoming for security experts and legal teams and why "DevSecOps" is now the term to be used to ensure security is no longer omitted from the value process.
Finally we'll have a vote if we keep the term "DevOps" as an all-inclusive representation for all stakeholders or if we need to start using "DevSecOps" to ensure the business understands can no longer ignore the importance of security.
In this presentation I'm providing reasons why you should consider privacy by design and protect the personal information of your customers using proven technology solutions and best practices.
Continuous Deployment, TDD and Continuous Integration is nothing new anymore and many of you are already veterans deploying multiple times each day code into production. But you’re still suffering from cutting corners and doing something quick on production when time is pressing, violating the processes you all worked hard on to get approved.
In this talk we take this very concept to the next level and show you how we used unconventional ways to deploy faster with less issues and regained control over a 10+ year old legacy application.
Test-driven Development (TDD) is still a subject all developers agree is a great thing, but never get around to actually doing it for many reasons. In this workshop, I use real-world business requirements on legacy code for which we need to fix bugs and add features, but we’re doing it in a TDD way.
On May 25, 2018 all companies collecting and processing data of people from within the European Union must comply to the General Data Protection Regulation or GDPR. In this talk we'll cover what the GDPR is and how it will impact businesses within the EU and abroad, what can be done to comply to this regulation and how to proceed further.
This talk will not provide you legal answers, but will give you technology solutions that will make your applications compliant to these regulations. Even if you're not processing data from the EU, these solutions will offer you better protection to the data you currently keep and will ensure that in the case of a breach, the impact will be minimum.
The days of a "simple" LAMP stack are behind us. We now rely on different types of technologies, applications and services to run our web based applications. With "the cloud" we have learned how to distribute our operations, but are we resilient when these cloud services are not available?
We have all heard about the major outages of Amazon and Azure in the past and many online services were impacted by those outages. So how can you protect yourself against being "offline" for hours or days and what are the tools you can use to protect yourself against it?
Learn how we protect our customers with distributed systems (cloud and on-prem) to mitigate outages and stay online even when the lights go out.
In December 2015, PHP 7.0 was released marking a new milestone for PHP and web application developers. We thought all was going to be easy to migrate to PHP 7.0. Unfortunately, many extensions and tools we use weren’t ready yet. In December 2016 PHP 7.1 was released, and the urgency to update became real as PHP 5.6 was nearing end-of-life. In this talk, I describe the analysis and the challenges we faced migrating towards PHP 7.1 so you can learn how to defeat those challenges if you plan to migrate too.
Frameworks give you a rich toolset to do complex tasks very easy and developers all love it. But then you need to update your framework from one version to another and things are falling apart because of the tight coupling with your business logic.
In this talk I show a couple of actual scenarios that went wrong when we moved from one framework to another and the solutions we applied to abstract business logic from framework logic. Even if you're not planning on migrating frameworks yet, decoupling is a good practice that will give you less headaches in the future.
Frameworks give you a rich toolset to do complex tasks very easy and developers all love it. But then you need to update your framework from one version to another and things are falling apart because of the tight coupling with your business logic.
In this talk I show a couple of actual scenarios that went wrong when we moved from one framework to another and the solutions we applied to abstract business logic from framework logic. Even if you're not planning on migrating frameworks yet, decoupling is a good practice that will give you less headaches in the future.
If you want to get things done and have your project up-and-running in no time, then you might want to take a look at Microsoft Azure. For PHP apps it's easy to set up and get going.
If you're an open source developer, Azure is a great platform to deploy your applications on. For personal or professional use, Azure comes with a full range of services that allow you to develop, scale and grow your application when you need it, how you need it.
On December 3, 2015 PHP 7.0.0 was released, starting a new milestone for PHP web application development and also announcing the final years for PHP 5, the version developers have loved for over a decade. A decent knowledge of PHP 5 syntax and behavior is required to understand changes that were made in PHP7.
If you build web applications you now have a huge responsibility: everything must be tested and secured. But how do you test and secure legacy applications or how do you get started with a new project using test-driven techniques to maximise quality and security without investing too much time in it.
In this workshop we will start with a clean project and build a simple catalogue application using test-driven and security-hardened techniques to achieve our goal. Once we have achieved our goal, we're going to apply the same on a legacy application.
You've got your tests, your metrics, your database migrations and your system provisioning automated, but how can you deploy everything with a push of a button and not be scared something goes wrong? Welcome to the continuous PHP Pipeline. In this talk I take the code, the tests, the metrics and the provisioners and show you how you can have a continuous delivery pipeline setup based on certain criteria you define upfront, your code gets automatically deployed to staging or to production with all the arbitrary tasks along with it. Never get stressed again about deployments. Make deployments as easy as committing to your repository and get home on time to enjoy your well deserved weekend.
A long time ago in code base not so far away...
It's a time of prosperity and happiness. Development Teams have improved their coding skills and are now very familiar with writing code with proper DocBlock comments and unit tests, safeguarding their code bases against unwanted behaviour. But the evil Internet is building their new weapon against the Development Teams and sneaks through the gaps still uncovered by tests.
Will the Development Teams be in time to safeguard their code base again and bring peace and balance in the universe?
So you have spent the last few years building PHP applications but now the business requirements have changed and you need to provide a full featured REST API. You could invest time, money and energy building it yourself, but have a look at Apigility. This is a full REST management application build on ZF2 allows you to tap into your existing PHP application and provide 100% REST endpoints to the outside world.
In this talk I go over the challenges we had to deal with creating our own REST implementation, throwing it all away because we only had 20% of the features of Apigility and setting up and managing Apigiltiy using an existing PHP application.
After this talk you will get a good understanding how to use Apigility to manage your REST API’s, while using your non-ZF2 application (Zend Framework, Symfony, Aura, ...). So you can invest time in building more features instead of trying to make your application REST compliant.
1. Zend Framework
“at your service”
Michelangelo van Dam
Dutch PHP Conference 2011 Amsterdam (NL)
2. Why a service ?
•- opening up existing API
internal applications
- external applications
- additional functionality
• support to more devices
• portability and flexibility
4. Example service
•- Time registration
list time sheets
- add a new task
- edit an existing task
- delete an existing task
5. MVC approach
•- time module
controllers (for displaying listing and forms)
- actions (for listing, adding, editing and deleting)
- models (for access to database)
- forms (for filtering, validation and rendering forms)
6. Common behavior
• all “logic” is put in the controller
• actions = API interface
•- downside
not flexible towards other clients
- difficult to provide maintenance
- not reusable design
7. Time Module
Time_IndexController
indexAction editAction
- lists registered tasks - displays a form
- links to the form - for adding task
- for adding task - for editing task
- for editing task
- for deleting task
registerAction deleteAction
- processes form data - deletes task
- validating data
- storing data in db
8. API Design
•- moving logic
out the controller
- in an API class
• structures the application
• is better testable
• is better maintainable
9. Time API
My_Api_Timesheet
listTasks registerNewTask
- lists registered tasks - for adding task
editExistingTask deleteExistingTask
- for modifying task - deletes task
15. listTasks
/**
* List all tasks for a given user
*
* @param int $user
* @return array
*/
public function listTasks($user)
{
$array = array ();
$timesheet = new Time_Model_Timesheet();
if (null !== ($result = $timesheet->fetchAll(array (
'user_id = ?' => $user,
), array ('date DESC', 'start_time ASC')))) {
foreach ($result as $entry) {
$array[] = $entry->toArray();
}
}
return $array;
}
16. registerNewTask
/**
* Register a new task
*
* @param int $user The ID of the user
* @param int $customer The ID of the customer
* @param int $task The ID of the task
* @param string $date A date formatted as YYYY-mm-dd
* @param string $start The starting time as HH:mm:ss
* @param string $end The ending time as HH:mm:ss
* @param string $description A short description
* @return bool TRUE if registration succeeded
* @throws My_Api_Timesheet_Exception
*/
17. registerNewTask
public function registerNewTask(
$user, $customer, $task, $date, $start, $end, $description)
{
$timesheet = new Time_Model_Timesheet();
$timesheet->setUserId($user)
->setCustomerId($customer)
->setTaskId($task)
->setDate($date)
->setStartTime($start)
->setEndTime($end)
->setDescription($description);
$validator = $this->_validate($timesheet);
if (false === $validator) {
require_once 'My/Api/Timesheet/Exception.php';
throw new My_Api_Timesheet_Exception('Invalid data provided');
}
$timesheet->save();
return true;
}
18. editExistingTask
/**
* Modify an existing task
*
* @param int $id The ID of an existing Task
* @param int $user The ID of the user
* @param int $customer The ID of the customer
* @param int $task The ID of the task
* @param string $date A date formatted as YYYY-mm-dd
* @param string $start The starting time as HH:mm:ss
* @param string $end The ending time as HH:mm:ss
* @param string $description A short description
* @return bool TRUE if registration succeeded
* @throws My_Api_Timesheet_Exception
*/
19. editExistingTask
public function editExistingTask(
$id, $user, $customer, $task, $date, $start, $end, $description)
{
$timesheet = new Time_Model_Timesheet();
$timesheet->setId($id)
->setUserId($user)
->setCustomerId($customer)
->setTaskId($task)
->setDate($date)
->setStartTime($start)
->setEndTime($end)
->setDescription($description);
$validator = $this->_validate($timesheet);
if (false === $validator) {
require_once 'My/Api/Timesheet/Exception.php';
throw new My_Api_Timesheet_Exception('Invalid data provided');
}
$timesheet->save();
return true;
}
20. deleteExistingTask
/**
* Modify an existing task
*
* @param int $id The ID of an existing Task
* @param int $user The ID of the user
* @return bool TRUE if registration succeeded
* @throws My_Api_Timesheet_Exception
*/
public function deleteExistingTask($id, $user)
{
$timesheet = new Time_Model_Timesheet();
$timesheet->setId($id)
->setUserId($user);
$validator = $this->_validate($timesheet);
if (false === $validator) {
require_once 'My/Api/Timesheet/Exception.php';
throw new My_Api_Timesheet_Exception('Invalid data provided');
}
$timesheet->delete(array (
'id = ?' => $timesheet->getId(),
'user_id = ?' => $timesheet->getUserId(),
));
return true;
}
21. _validate
/**
* Private validation method
*
* @param Time_Model_Timesheet $timesheet
* @return bool TRUE if validated, FALSE if invalid
*/
private function _validate(Time_Model_Timesheet $timesheet)
{
$result = true;
$validator = new Time_Form_Register();
$customer = new Time_Model_Customer();
$task = new Time_Model_Task();
$validator->getElement('customer_id')->setMultiOptions($customer->toSelect());
$validator->getElement('task_id')->setMultiOptions($task->toSelect());
if (!$validator->isValid($timesheet->toArray())) {
$result = false;
}
return $result;
}
28. REST Server
<?php
class Time_RestController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$server = new Zend_Rest_Server();
$server->setClass('My_Api_Timesheet');
$server->handle();
}
}
29. REST Client
<?php
class Time_RestClientController extends Zend_Controller_Action
{
protected $_client;
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$this->_client = new Zend_Rest_Client('http://www.demo.local/Time/rest');
}
public function indexAction()
{
$this->_client->listTasks(2);
Zend_Debug::dump($this->_client->get());
}
}
32. You can help !
•- find a bug ?
test it
- report it
- send a patch/fix
• need a non-existing component
- submit proposal
• like Zend Framework
- blog about it
- talk about it
33. ZF Bug hunt days
Zend Framework Bughuntdays
every 3rd Thursday and Friday of the month
http://framework.zend.com/issues
IRC (irc.freenode.net) #zftalk.dev
prizes:
Free subscription for 1 year on php|Architect magazine
Zend Framework t-shirt
recognition and appreciation of the community