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

Tomas Votruba:
Hidden Gems of PHP Packages: SymfonyFinder and SplFileInfo
Aug 14, 2018 @ 15:55:09

Tomas Votruba has continued his series covering the "hidden gem" packages he's found in his PHP development. In this latest post he focuses on two new pieces of functionality: the Symfony/Finder package and SplFileInfo.

The series on not-so-well-known packages that might save your ass more than you think continues. Today we look on files as objects.

He starts by providing some examples of where he makes use of the Finder package and how it makes working with files easier. He then shows how to get the package installed, a simple example of how to use it and some of the functionality that's included. He also details the SplFileInfo functionality that comes with the package and what information it can provide about a file.

tagged: package hiddengem tutorial symfony finder splfileinfo

Link: https://www.tomasvotruba.cz/blog/2018/08/13/hidden-gems-of-php-packages-symfony-finder-and-spl-file-info/

Symfony Finland:
Using Symfony Finder and YAML components to transform Drupal 8 configurations to eZ
May 10, 2016 @ 15:58:31

On the Symfony Finland blog there's a tutorial posted showing how to translate Drupal 8 configurations into ones for eZ Platform using a bit of code inside a Symfony command.

Bolt CMS, Drupal 8 and eZ Platform all content management systems that use Symfony in one form or another. All of them use YAML to store configurations of content types and other system properties. This is great as it makes transferring between different formats quite straightforward.

This could be done by hand, but ideally configurations can be converted programatically. In this article we'll take a look at how to transfer content types from Drupal 8 to eZ Platform using a standard Symfony Command.

He starts with some background about the two configuration types (Drupal 8 and eZ Platform) before getting to the actual code to make the transformation. The code translates the Drupal 8 configurations over to the Kaliop Migrations format that can then be used in various environments. They include an example of the resulting configuration structure and, finally, the code to make the translation (allowing for multiple object types too).

tagged: symfony finder yaml component transform druapl8 configuration ezplatform

Link: https://www.symfony.fi/entry/using-symfony-finder-and-yaml-to-transform-drupal-8-configurations-to-ez-platform

ServerGrove Blog:
Symfony2 components overview: Finder
Mar 26, 2014 @ 17:12:36

The ServerGrove blog has posted the latest in their series focusing in on the components in the Symfony2 framework. In this new post they look at the Finder component, used to locate files or directories in your project.

This is the 9th post in this series about the Symfony2 components. Today’s post covers one of the most popular PHP packages: the Finder component. According to Packagist it is the 14th most used PHP package, and the 3rd Symfony2 component, only after the EventDispatcher and Console ones.

They walk you through the installation (via Composer) and show some code examples of it in use, including the output. They list out some of the options you can specify when using the component and go "under the hood" to detail the interfaces, adapters and objects that make it all work. There's also a list of other applications (outside of the Symfony2 framework) that use it as an independent package.

tagged: symfony2 component finder tutorial

Link: http://blog.servergrove.com/2014/03/26/symfony2-components-overview-finder/

Michael Nitschinger's Blog:
Custom Finders with Lithium
Jun 03, 2011 @ 14:03:25

Michael Nitschinger has another post that'll interest the Lithium framework users out there - how to create custom finders to help in code reuse for database requests.

Finders assist you with often-used database queries so you don't have to write them over and over again. Out of the box, Lithium provides you with a bunch of them: all, first, count list and "magic finders like" findById or findFirstById. How these are constructed in the core is not relevant for now, but Lithium provides you with a mechanism to write your own finders easily.

He starts with a look at the bundled finder, showing how it uses a _findFilters method to create the default filter and pass it into your configuration. He covers the parameters you'll need to define and an example of making a Task to create a new one. His example sets a limit of five results on the response. He also mentions the ability to add a custom finder to your model, loaded in the _init() automatically.

tagged: custom finder lithium tutorial database

Link:

Fabien Potencier's Blog:
Find your Files
Apr 22, 2010 @ 19:45:09

Fabien Potencier has a new post today about an update he's made to an aging bit of code for the Symfony framework to find files on the local filesystem - sfFinder.

I used the opendir, readdir, and closedir native PHP functions, and it did the job quite well. The PHP class was named sfFinder, and it can still be found in all symfony versions. Even if the class is bundled with symfony, I know that a few people use it for all kind of stuff, not necessarily related to symfony. But the code starts to show its age; first because I learned a lot since then about PHP, and also because there is a better way now. Enter iterators!

He shows an example of how to use Iterators to search through directories recursively (RecursiveDirectoryIterator) and locate a certain filename. He also looks at making it more OOP and including filtering to remove files from the search. He's packaged up some of this logic into a new Symfony component - the Finder component - that can be used to locate files in a path, be restricted to a depth for the search, match regular expressions file names, filter by file size and much more.

If you'd like to dig into the code, check out this page on github for this new component (PHP 5.3 only).

tagged: find file symfony component finder iterator

Link:

Federico Cargnelutti's Blog:
Implementing Dynamic Finders and Parsing Method Expressions
Mar 23, 2010 @ 18:07:47

In a new post to his blog Federico Cargnelutti takes a look at features available in Ruby and Grails - dynamic finders and method expressions and introduces a PHP library that can parse them.

A dynamic finder method looks like a normal method invocation, but the method itself doesn’t exist, instead, the method is generated dynamically and processed via another method at runtime. [...] A method expression is made up of the prefix such as "findBy" followed by an expression that combines one or more properties.

He includes a few examples of each, the finders and expressions, and talks about the class he's developed to handle the method expressions in PHP. It's based on a simple format defining the method, attribute, expression and operator. Code snippet examples are included for SQL statement generation and object parsing. The code for the class is included in the post.

tagged: finder method expression dynamic tutorial

Link:

Community News:
Zipline Interactive Updates PHP Function Finder (Windows Gadget)
Feb 15, 2008 @ 18:59:00

Ryan from Zipline Interactive submitted an update about the latest version of their "Function Finder" they've created for Windows (and is mentioned here):

Zipline Interactive has released the second version of their free PHP Function Finder Gadget for Windows Vista. The tool can be downloaded directly from the Zipline Interactive website at: http://www.gozipline.com/23,phpfunctionfindergadget. You can also download the latest version by going to the PHP.net website sidebar page located at: http://www.php.net/sidebars.

This new version is quite a bit smaller (physically) than its predecessors and is rectangular so it fits a bit better alongside other gadgets. They also fixed a bug that was causing a blink to happen when the search was performed.

Grab this latest download here.

tagged: zipline interactive function finder gadget windowsvista

Link:

SitePoint PHP Blog:
Wide Finder in...errr...PHP
Nov 01, 2007 @ 13:24:00

In a new post on the SitePoint PHP blog today, Harry Fuecks has created a "wide finder" based on a project put together by Tim Bray.

Tim set a simple, but very much real-world challenge; write an app that determines the top 10 most popular blogs from his Apache access log. It should be fast and readable, with a subtext of illustrating how "language X" copes in terms of parallel processing and utilizing "wider" (many processor) systems.

Since PHP natively doesn't support multi-threading (well), Harry opted to go with an approach using curl_multi_exec instead. There's two pieces to the puzzle - the mapper to grab the information and extract the data and the reducer that makes the calls to grab the information from the log files.

tagged: wide finder timbray apache log popular reducer mapper wide finder timbray apache log popular reducer mapper

Link:

SitePoint PHP Blog:
Wide Finder in...errr...PHP
Nov 01, 2007 @ 13:24:00

In a new post on the SitePoint PHP blog today, Harry Fuecks has created a "wide finder" based on a project put together by Tim Bray.

Tim set a simple, but very much real-world challenge; write an app that determines the top 10 most popular blogs from his Apache access log. It should be fast and readable, with a subtext of illustrating how "language X" copes in terms of parallel processing and utilizing "wider" (many processor) systems.

Since PHP natively doesn't support multi-threading (well), Harry opted to go with an approach using curl_multi_exec instead. There's two pieces to the puzzle - the mapper to grab the information and extract the data and the reducer that makes the calls to grab the information from the log files.

tagged: wide finder timbray apache log popular reducer mapper wide finder timbray apache log popular reducer mapper

Link:


Trending Topics: