Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

AWS Developer Blog:
Introducing support for Amazon S3 Select in the AWS SDK for PHP
Sep 17, 2018 @ 14:28:17

On the AWS Developer Blog they've posted an announcement about the release of support for Amazon S3 Select in the AWS SDK for PHP. This "select" functionality allows for more powerful queries on the contents currently in your S3 buckets.

We’re excited to announce support for the Amazon Simple Storage Service (Amazon S3) SelectObjectContent API with event streams in the AWS SDK for PHP in version 3.67.11. Using Amazon S3 Select, you can query for a subset of data from an S3 object by using simple SQL expressions.

Amazon S3 streams the responses as a series of events, instead of returning the full API response all at once. This enables your applications to process the parts of the response as the application receives them. To support this new API behavior, the AWS SDK for PHP supports processing these events from the API response.

The post goes on to give a few examples of the use of the "select" functionality, querying the contents of a CSV file using the familiar SQL format. Example code is also included using the SelectObjectContent and EventParsingIterator to select and retrieve the results.

tagged: amazon aws s3 select support release awssdk tutorial

Link: https://aws.amazon.com/blogs/developer/introducing-support-for-amazon-s3-select-in-the-aws-sdk-for-php/

KillerPHP.com:
PHP vs Python in 2018?
Nov 27, 2017 @ 19:43:35

On the KillerPHP.com site there's a new post that compares two popular languages - PHP and Python and tries to answer the question "Which one should I learn?"

One question I get often, is which programming language should you learn? I’ve been getting this question for years!

Things change in the programming world, languages come and go. But the good news is that the basics, the core concepts and techniques, are 90-95% the same in all the modern programming languages. [...] What that means, is that your programming language choice, isn’t nearly as critical as you’d think. Why? Well, once you know one programming language, it is easy as apple pie to switch to another!

He then gives some of his own thoughts about how you could decide which language you should pick including the kinds of programming (target result) and what kinds of jobs you can get with each.

tagged: python language comparison select jobs programming

Link: https://www.killerphp.com/articles/php-vs-python-in-2018/

Marc Aube:
Design Pattern: Specification
May 25, 2015 @ 17:19:47

Marc Aube has a new post to his site that introduces you to the specification design pattern, a technique that's useful for ensuing the current state of an object is valid.

The specification pattern is a software design pattern used to codify business rules that state something about an object. These simple predicates determine if an object's state satisfies a certain business criteria. They can then be combined to form composite specifications using logical operators. Use a specification to encapsulate a business rule which does not belong inside entities or value objects, but is applied to them.

He suggests a few things the pattern could be useful for like validating the current state or define how an object should be created. He gives a few more "real world" examples and then gets into the code to create a custom specification. In his "CustomerIsPremium" spec he defines a single method on an interface to determine if the Customer given is correct. He then creates a class instance and encapsulates the logic inside its "isSatisfiedBy" method. He also includes a bit more complex example, showing how to create a composite specification for handling grouping like "and", "or" and "not" assertions. Finally he looks at how to build specifications that can be passed in and used as selection criteria. He does point out that this can leak database handling into the specification layer, however, and should really be avoided without a inversion of control method in place.

tagged: specification designpattern pattern example composite select validate

Link: http://marcaube.ca/2015/05/specifications/

MaltBlue.com:
ZendDbSqlSelect - The Basics (Columns, Limit & Order)
Jul 02, 2013 @ 14:53:32

Matthew Setter has posted the third part of his series looking at the Zend Framework 2's DbSqlSelect component and its use. In this latest (and last) tutorial, he talks more specifically about columns, limiting and ordering.

Welcome to the third and last part in this series, introducing you to working with the ZendDbSqlSelect classes in Zend Framework 2. In part one we looked at building SQL Where clauses using the where related functions, predicates and closures, as well as compound queries. In part 2, we looked at all forms of SQL joins as well as a slightly more esoteric feature of SQL – UNIONS. Here, in part 3, in the words of Coldplay, we’re going back to the start, and looking at the fundamentals.

He looks at three specific elements - the class constructor, the "limit" and "order" functions and the "Expression" class. He includes sample code showing how to create the class - one normally and one bound to a specific table. The next example shows how to define the columns to be selected using the "select" method. Finally, he shows the use of the "Expression" objects to perform SQL operations in the query (like "COUNT").

tagged: zendframework2 db sql select series part3 column limit order

Link: http://www.maltblue.com/tutorial/zend-db-sql-the-basics

DZone.com:
PHPUnit_Selenium
Jan 20, 2012 @ 15:12:18

On DZone.com today Giorgio Sironi has a quick tutorial showing you how to set up and use the PHPUnit_Selenium component in the latest releases of the popular testing software.

With the 1.2 release, PHPUnit_Selenium supports (basically) for the first time the Selenium 2 WebDriver API. While PHPUnit_Selenium already worked with Selenium 2, it did so only by using the Selenium 1 emulation included in the jar; now it provides an object-oriented API right natively supported in a base PHPUnit test case, shipped in PHPUnit's PEAR channel.

He includes the steps you'll need to pull it from the PEAR channel and how to set up a test case based on the PHPUnit_Extensions_Selenium2TestCase object. He gives a few examples of how to select various components on the page (via CSS selectors and XPath), assert that the right information is there and interact with forms.

tagged: phpunit selenium install unittest tutorial example select interact

Link:

Devis Lucato's Blog:
Select: Inversion of Control
Dec 14, 2011 @ 19:34:53

In a recent post to his blog Devis Lucato introduces the "Inversion of Control" design pattern and shares an implementation he's created as an illustration - a Service Locator called Select.

[In a Service Locator] all the dependencies are provided by a builder, which serves as a registry of dependencies and/or service definitions. The service locator knows how to instantiate each dependency. Such service exposes methods like 'getMailer()', 'getLogger()' etc. A service locator centralises the configuration detailing classes and parameters involved on objects instantiations.

He includes some sample code showing the structure of a Select implementation using a "Mailer" identifier and definitions of the classes to load for it. He also includes a bit of documentation of the (simple) API you can use to work with the tool - setting namespaces, replacing class definitions, creating definitions and finding the resource associated with a definition (to name a few).

tagged: inversion control designpattern select implementation

Link:

Court Ewing's Blog:
Create and Validate a Choice List in a Symfony 2 Form
Aug 17, 2011 @ 13:28:21

Court Ewing has written up a new post to his blog about creating a "choice" list (a select list as defined by Symfony 2) with dynamic options and validating the resulting submission. His example uses Doctrine 2 entities to work with most of the data handling.

A standard select list can be created using Symfony's choice field type; it is pretty clear how to create a new choice field with simple, non-dynamic options (e.g. gender), but it gets a little more complicated when you want to create and validate a dynamically generated choice list.

He includes the code for a simple entity, a Post model to fetch the category information and the set up of the form element - a select list of post types/categories. He also includes a bonus section showing how you can achieve the same thing without a model to bind to. The code's a little bit more complex than the previous example, but it's basically just reproducing some of the validation and fetching logic manually.

tagged: create validate tutorial symfony2 form select choice dynamic

Link:

Ian Christian's Blog:
Creating a custom form field type in Symfony 2
Aug 16, 2011 @ 17:04:37

Ian Christian has added a new post to his blog today showing how you can create a custom form field type in Symfony 2 by extending the AbstractType.

I am finally starting to dive into symfony 2 properly. Yes - it's taken a while, work has taken me in different directions! I found myself needing to create a custom form field type pretty quickly, but couldn't find much in the way of documentation to do so, so I thought I'ld throw it up here; partly to help others, but mostly to get feedback to make sure I'm not approaching this from the wrong angle.

He includes the code that creates his custom "Person" model and the class to create his "transport type" select box that pulls in its values from a "choice list" class. He registers it in his bundle and it can then be included in his buildForm() method just like any other form field.

tagged: symfony tutorial custom form field select abstract

Link:

Rob Allen's' Blog:
A Zend Framwork compound form element for dates
Mar 21, 2011 @ 17:23:08

In a new post to his blog today Rob Allen shows you how to create compound form element handling in a Zend Framework application thanks to some custom work with Zend_Form and Zend_View extensions.

A little bit of googling found this site http://codecaine.co.za/posts/compound-elements-with-zend-form which has not unfortunately disappeared, so the code in this article owes a lot of the author of that article. It turns out to be remarkably simple to create a single Zend Form element that is rendered as multiple form elements. We create an element object and a view helper object and we're done.

He shows how to create a custom form date helper that extends the base XHTML to create the isValid/getValue methods for handling the complex date input. There's also the code for the view that creates the custom date input and repopulates the content if there's a need.

tagged: zendframework complex date select zendform zendview

Link:

Jani Hartikainen' Blog:
Database backed Zend_Form elements
Mar 09, 2009 @ 13:45:27

Jani Hartikainen has a new post that should interest the Zend Framework developers out there - a look at automatically querying the database to fill in the right option values for a Zend_Form element.

It’s not very tricky to query a database, and fill a Zend_Form element’s possible values from the resultset, but it can be quite boring and extraneous code... We could also create an element which we can give some SQL, and it’ll fill itself automatically! This way you can even define database-backed elements in XML or INI configuration files.

He starts with a simple Select element type example and builds from there. He creates a DbSelect layer for the element and with the help of a main method, _performSelect, the script can create a new instance of the CU_Form_Element_DbSelect to pull in the options from the SQL (given in the "dbSelect" parameter).

tagged: database backend select option zendform zendframework query

Link:


Trending Topics: