News Feed

News Archive
feed this:

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

Full Stack Radio:
10 Type Safety Roundtable with Ryan Tablada and Matt Machuga
February 24, 2015 @ 09:15:55

In the latest episode of the Full Stack Radio podcast - episode #10, host Adam Wathan has two guests to talk about programming in a language with dynamic types versus static types.

In this episode, Adam talks with Ryan Tablada and Matt Machuga about the philosophical differences between programming in a statically typed language vs. a dynamically typed language. They talk about things like explicit interfaces vs. duck typing, function calling vs. message passing, and some of the recent RFCs around optional typing in the PHP community.

You can listen to this latest episode either through the in-page audio player or by subscribe to their feed to get the latest episodes as they're released.

0 comments voice your opinion now!
fullstackradio ep10 typesafety strong dynamic language podcast mattmachuga ryantablada


Web Mozarts:
Resource Discovery with Puli
January 15, 2015 @ 11:14:53

Bernhard Schussek has written up a new post to the Web Mozarts blog talking about resource discovery with Puli. Puli is a management tool for the non-PHP files in your applications (CSS, Javascript, YAML, etc). In this post he talks about the use of the discovery component and its use of resource binding.

Many libraries support configuration code, translations, HTML themes or other content in files of a specific format. The Doctrine ORM, for example, is able to load entity mappings from special XML files. When setting up Doctrine, we need to pass the location of the *.dcm.xml file to Doctrine's XmlDriver. That's easy as long as we do it ourselves, but what if someone else uses our package? How will they find our file? What if multiple packages provide *.dcm.xml files? How do we find all these files? We need to remove the appropriate setup code after removing a package [and] we need to adapt the setup code after installing a new package. Multiply this effort for every other library that uses user-provided files and you end up with a lot of configuration effort. Let's see how Puli helps us to fix this.

He talks about the concept of package roles in the tool, breaking them down in resources and providers. He then shows how Puli makes it possible to discover resources by defining a type via Puli and the code for the discovery process. He then binds the XML configuration definition and executes a "find" to ensure it's configured correctly. Finally, he shows the process to use Puli in this Doctrine example allowing it to locate and use the XML mappings dynamically via a custom driver.

0 comments voice your opinion now!
puli resource discovery dynamic doctrine component


Qafoo Blog:
Utilize Dynamic Dispatch
October 16, 2014 @ 11:52:18

On the Qafoo blog today Tobias Schlitt talks about dynamic dispatch, what he calls a "fundamental concept of OOP" to help provide clean, clear interfaces in the code.

I want to use this blog post to illustrate the concept of dynamic dispatch which I use a lot recently to motivate creating clean OO structures in my trainings. In my experience, this helps people to understand why we want to write code in this way. After that I will show why traits are bad in this direction.

He explains the concept of "dynamic dispatch" by starting from the beginning...with procedural PHP code. He looks at the usual flow of this kind of application that call shared functions in a "top down" fashion. He looks at what would happen if new logging needs were introduced (use a new method? patch the current one?) and the dependencies that can be introduced because of it. With this in mind, he continues and talks about how the "dynamic dispatch" happens during the code execution, splitting the log request based on the information it's given instead of different implementations for each. He points out that using a trait doesn't allow for this abstraction and instead embeds the code into the class itself, re-introducing the original problem.

0 comments voice your opinion now!
dynamic dispatch oop concept example logger trait compare


Joshua Thijssen:
Dynamic form modification in Symfony2
March 20, 2014 @ 09:42:16

Joshua Thijssen has a new post to his site looking at a way to dynamically modify forms in a Symfony2-based application. Form handling can be a bit tricky (especially with more complex elements), and modifying them on the fly can be even more difficult.

Sometimes (or actually, a lot of the time), handling forms will go beyond the basics. And even though symfony2 gives you out-of-the-box a really clean way of creating forms, it sometimes just isn't enough. Fortunately, you are not alone in writing forms, and many posts exists with information on how to handle complex forms. In this post, I will try and demonstrate how to create a dynamic form where you can select a city based on the chosen province.

His example lets the user pick their province and then populates the other select with cities in that area. He includes the code for the form to create these two selects and how to pull out the list of provinces to populate the first. He goes through each part of the example code explaining the methods, what they're doing and how a pre-submit event can be used to populate the second list.

0 comments voice your opinion now!
dynamic form value modification symfony2 tutorial


SitePoint PHP Blog:
Managing Gettext Translations on Shared Hosting
February 11, 2014 @ 13:09:19

On the SitePoint PHP blog today Aurelio De Rosa makes some recommendations about handing gettext translations on shared hosting. The problem with shared hosting is the need to reset the web server (Apache) to get it to read the updated translation files. His workarounds uses an external script that can dynamically pull in the latest translations without the restart.`

For serious translations we can use Gettext. This approach enables us to have different files for every targeted language which helps in maintaining separation between the business logic, the presentation layer, and the translations (which we can see as an add-on of the presentation layer). With Gettext, we can parallelize the process because while we're working on some features of the website, translators can still work on translations using software like gettext functionality to set the current language and extract a "HELLO_WORLD" string. He then moves on to the use of the Audero Shared Gettext library. This library creates a "mirror" of the translation file requested and forces those updates into the current domain. Code examples of its use are included showing a basic pull and merge process.

0 comments voice your opinion now!
gettext tranlsation dynamic loading webserver shared hosting tutorial

Configuration is code
November 20, 2013 @ 10:54:12

In this recent post to Giorgio Sironi talks about how, despite it commonly not being intended this way, configuration files usually end up being "code".

You start out with a simple .ini file [and] after a while, you customize its values by deployment environment. [You] then substitute values in it, to remove duplication or substitute constants, for that matter. Finally, you start supporting dynamic values, because this gives you more flexibility. The thesis of this article is that an efficient solution for supporting the more complex use cases of configuration can be found, without piling up proprietary or open source libraries to parse more and more complex configuration files. This solution, namely, is to use a more powerful language: your own dynamic programming language.

He looks at the "back in the day" configuration types that Java frameworks used - mostly XML files with a tight coupling to the servlet using it. He steps back a bit and looks at what he calls the "properties of code" and relates it to this dynamic language for configuration he's been talking about.

0 comments voice your opinion now!
configuration dynamic language properties


Gonzalo Ayuso:
Dynamic routes with AngularJS and Silex
July 10, 2013 @ 10:58:11

Gonzalo Ayuso has a new post today showing how to set up dynamic routing for a Silex-based application using an AngularJS frontend.

These days I'm playing with AngularJS. Today I want to experiment with dynamic routes. Let me show your an example. It's very simple but: What happens if our application is big and it grows fast? We need to add new lines and reload the browser. With AngularJS we can add paramenters to the routes.

He shows how to work with these route parameters and how to use the partial in a DynamicController. He also gives some sample PHP code showing how it all works together with Silex and a Twig provider. The Twig provider changes the tags that it looks for away from the curly braces to the square ones (Angular uses the same tags for its templates too so they'd get confused otherwise).

0 comments voice your opinion now!
silex angularjs dynamic routing tutorial

Master Dynamic Content with WordPress Shortcodes
July 09, 2012 @ 11:47:13

On today there's a new tutorial for the WordPress users out there looking to work with dynamic content and shortcodes to make your site easier to use and to bring more content to user's attention.

The advantages to using shortcodes are obvious. First and foremost, it allows page designs to become far more unique. It also relieves the website administrator from having to create a large list of custom fields in order to perform basic content insertion. [...] And, finally, shortcodes allow a design to come alive and be truly dynamic and interesting to the end user. Too many WordPress blogs and magazine websites have adhered to the format of a big title, a standard block of text, and comments. That no longer has to be case.

They talk about using the "functions.php" file for the custom functionality, who to use them in your posts and how to use them in the theme-specific instances. Using the "add_shortcode" you can relate these custom functions to their codes for both simple and more advanced calls (code included).

0 comments voice your opinion now!
wordpress dynamic content shortcode
Generating Invoices with Zend_Pdf
October 10, 2011 @ 09:07:15

On today there's a new tutorial about using the Zend_Pdf component of the Zend Framework to generate invoices from the billing data in your application.

The PDF format is currently the most used format to exchange documents. If you provide your website users with printable versions of invoices, event tickets and other similar documents, you'll most likely want to generate them as PDFs on the fly. In this article you will see how you can use Zend_Pdf to auto-generate PDF invoices.

The concept is pretty simple - take the rows of invoice data from your system and inject them into a new PDF document. They show you how to create an invoice layout that includes that data, a header with your company name, invoice-related information and the total/amount due at the bottom. The full code is included to help you create the Zend_Pdf object, apply the text to it (based on location in the document) and working with the default font. You can download the full source from github.

0 comments voice your opinion now!
invoices zendpdf zendframework dynamic tutorial pdf

Court Ewing's Blog:
Create and Validate a Choice List in a Symfony 2 Form
August 17, 2011 @ 08: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.

0 comments voice your opinion now!
create validate tutorial symfony2 form select choice dynamic

Community Events

Don't see your event here?
Let us know!

opinion extension laravel conference release laravel5 wordpress development api interview community framework unittest library language introduction podcast series voicesoftheelephpant middleware

All content copyright, 2015 :: - Powered by the Solar PHP Framework