Fabien Potencier"Create your Own Framework" Series Update (4.7.2015, 22:00 UTC)

Three years ago, I published a series of articles about how to create a framework on top of the Symfony components on this blog.

Along the years, its contents have been updated to match the changes in Symfony itself but also in the PHP ecosystem (like the introduction of Composer). But those changes were made on a public Github repository, not on this blog.

As this series has proved to be popular, I've decided a few months ago to move it to the Symfony documentation itself where it would be more exposed and maintained by the great Symfony doc team. It was a long process, but it's done now.

Enjoy the new version in a dedicated documentation section, "Create your PHP Framework", on symfony.com.

Link
SitePoint PHPTurning a Crawled Website into a Search Engine with PHP (3.7.2015, 16:00 UTC)

In the previous part of this tutorial, we used Diffbot to set up a crawljob which would eventually harvest SitePoint’s content into a data collection, fully searchable by Diffbot’s Search API. We also demonstrated those searching capabilities by applying some common filters and listing the results.

Diffbot Logo

In this part, we’ll build a GUI simple enough for the average Joe to use it, in order to have a relatively pretty, functional, and lightweight but detailed SitePoint search engine. What’s more, we won’t be using a framework, but a mere total of three libraries to build the entire application.

You can see the demo application here.

This tutorial is completely standalone, and as such if you choose to follow along, you can start with a fresh Homestead Improved instance. Note that in order to actually fully use what we build, you need a Diffbot account with Crawljob and Search API functionality.

Bootstrapping

Moving on, I’ll assume you’re using a Vagrant machine. If not, find out why you should, then come back.

On a fresh Homestead Improved VM, the bootstrapping procedure is as follows:

composer global require beelab/bowerphp:dev-master
mkdir sp_search
cd sp_search
mkdir public cache template template/twig app
composer require swader/diffbot-php-client
composer require twig/twig
composer require symfony/var-dumper --dev

In order, this:

  • installs BowerPHP globally, so we can use it on the entire VM.
  • creates the project’s root folder and several subfolders.
  • installs the Diffbot PHP client, which we’ll use to make all calls to the API and to iterate through the results.
  • installs the Twig templating engine, so we’re not echoing out HTML in PHP like peasants :)
  • installs VarDumper in dev mode, so we can easily debug while developing.

Continue reading %Turning a Crawled Website into a Search Engine with PHP%

Link
Lorna MitchellPHP 5.4 and Short Tags (3.7.2015, 09:07 UTC)

PHP 5.4 isn't exactly new; in fact the opposite is true! PHP 5.4 is end of life, but as our adoption rates show, as a community, PHP people aren't especially good at upgrading! I'm getting lots of questions now because some of the hosting providers, notably including Acquia's hosting, are finally upgrading away from those 5.2 and 5.3 offerings.

One thing in particular is tripping people up: the short open tag. I've had a few questions on this so here's the advice I am giving to clients and friends.

What Actually Changed

The short_open_tag configuration directive was removed, but the short echo syntax <?= is always available.

How To Upgrade Your Codebase

  • If you have <?= in your templates, leave it alone, those will still work
  • If you have short tags <? in your code, including in any of your libraries, then you need to do a global find-and-replace and turn them all into <?php

If you have short tags somewhere in your codebase, you probably won't get errors, you'll just suddenly start seeing PHP code in your output as PHP doesn't recognise the tag and therefore doesn't evaluate the code! To find them, try searching for <? followed by a whitespace character.

Hopefully that helps; there are a few gotchas to getting upgraded from older versions (especially from PHP 5.2) but this particular gotcha really isn't a problem and the instructions here should see you through.

Lorna is an independent web development consultant, author and trainer, available for work (interesting projects only). This post was originally published at LornaJane

Link
Anna FilinaConverting a Joined Resultset Into a Hierarchy (2.7.2015, 20:45 UTC)

I needed nested resultsets in some projects. I’ve seen a lot of StackOverflow chatter which essentially pointed people towards Doctrine or Propel ORMs, which was overkill when you didn’t want mapping or even model classes.

I built a very small function that will transform joined results into a hierarchy. This avoids using heavy ORMs if you just need this small feature. It’s 74 lines of code and really easy to use. Since it’s open source, feel free to improve it.

You’d give it a statement like this:

SELECT album.id AS albums__id, photo.id AS albums__photos__id
FROM album
LEFT JOIN photo ON photo.album_id = album.id;

and it will produce something this:

stdClass Object
    (
        [albums] => Array
            (
                [1] => stdClass Object
                    (
                        [id] => 1
                        [photos] => Array
                            (
                                [1] => stdClass Object
                                    (
                                        [id] => 1
                                    )
                            )
                    )
            )
    )

Optionally, you can replace stdClass by your own classes with just a single parameter.

It’s on my GitHub. All the documentation is there.

Link
Brandon SavageWhy we program (2.7.2015, 13:00 UTC)

As programmers, we don’t really make anything. Oh sure, we write code, design applications, and create open source libraries. Yet we so willingly refactor away our hard work, delete and close down apps, and at the end of the day, really have little tangible outcome from the work that we do. Unlike a furniture maker […]

The post Why we program appeared first on BrandonSavage.net.

Link
PHP ClassesMySQL Extension, Going, Going, almost Gone (2.7.2015, 08:06 UTC)
By Dave Smith
When the warnings change from "the extension may go away" to "the extension will go away", things just became serious. For some of us, the race is on to keep our projects from collapsing.

Read this article to learn about a method to analyze your PHP code and find functions and extensions that are being deprecated, as well a quick and easy solution to deal with the removal of the MySQL extension in PHP 7 or even sooner in your current hosting provider.
Link
Chuck BurgessCorrupted .git/config Files and Jenkins (1.7.2015, 21:27 UTC)
Link
SitePoint PHPCrawling and Searching Entire Domains with Diffbot (1.7.2015, 16:00 UTC)

In this tutorial, I’ll show you how to build a custom SitePoint search engine that far outdoes anything WordPress could ever put out. We’ll be using Diffbot as a service to extract structured data from SitePoint automatically, and this matching API client to do both the searching and crawling.

Diffbot logo

I’ll also be using my trusty Homestead Improved environment for a clean project, so I can experiment in a VM that’s dedicated to this project and this project alone.

What’s what?

To make a SitePoint search engine, we need to do the following:

  1. Build a Crawljob which will index and process the entire SitePoint.com domain and keep itself up to date with newly published content.
  2. Build a GUI for submitting search queries to the saved set produced by this crawljob. Searching is done via the Search API. We’ll do this in a followup post.

A Diffbot Crawljob does the following:

  1. It spiders a URL pattern for URLs. This does not mean processing - it means looking for links to process on all the pages it can find, starting from the domain you originally passed in as seed. For the difference between crawling and processing, see here.
  2. It processes the pages found on the spidered URLs with the designated API engine - for example, using Product API, it processes all products it found on Amazon.com and saves them into a structured database of items on offer.

Continue reading %Crawling and Searching Entire Domains with Diffbot%

Link
PHP ClassesOnline Boot Camp for Modernizing PHP Legacy Applications (1.7.2015, 04:01 UTC)
By Paul M. Jones
Over the years the recommended practices to develop PHP applications have evolved but applications developed in the past were not maintained and suffer with several problems for being what are usually called legacy applications.

Read this article to learn how you can participate in an online course to learn the best practices to modernize your legacy PHP applications.
Link
Nomad PHPProtected: NEPHP Logos (30.6.2015, 20:47 UTC)

There is no excerpt because this is a protected post.

The post Protected: NEPHP Logos appeared first on Nomad PHP.

Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP