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

Grok Interactive:
Importing Large CSV Files with PHP Part 1: Import Using One Query
Sep 23, 2015 @ 12:19:33

The Grok Interactive blog has posted a tutorial, the first part in a series, showing you how to work with large CSV files in PHP.

Importing CSV files into your application can become a problem when the file is really big, > 65,000 rows big. Each row of the file needs to be parsed, converted into an object, and then saved to a database. All of this needs to happen within a 30 second timeout window. It may sound like an impossible task, but there are actually a couple of solutions that can solve this problem. While working on a project at Grok, I was tasked with doing exactly that.

He talks about the method he tried initially for parsing the large files, splitting it up into different files and processing them as chunks. He points out that it relies on the file system, though, and this made it difficult to debug. He finally came up with a different, more simple solution: importing the files directly into MySQL via a LOAD DATA LOCAL INFILE command. He shows how to set this up in a controller and "importer" class that handles the upload and import via the importFileContents method (complete code included). He walks through what the code is doing and includes a few notes about the configuration of the database connection to specify additional options on the PDO connection to allow the local file load.

tagged: tutorial csv file import large processing chunk mysql load file query

Link: http://www.grok-interactive.com/blog/import-large-csv-into-mysql-with-php-part-1/

Robert Basic's Blog:
Importing Symfony2 security settings from a bundle
Aug 25, 2011 @ 11:58:40

In a new post to his blog Robert Basic takes a brief look at importing Symfony2 security settings from a bundle he's been creating back into the main configuration.

I started to work on/figuring out the security part in Symfony2 and one part where the docs fail so far is to explain how to import security settings from a bundle. Once I put some thinking into it, it’s pretty easy actually. Simply import the needed security file in your main config file.

His trick is to use the "imports" key in his YAML config file to define the resource to pull from in his config.xml. More information on the format of the security file can be found here in the Symfony documentation. It helps you define authentication mechanisms, authorization models and working with access control and roles.

tagged: import security setting symfoyny2 bundle configuration resource


Lorna Mitchell's Blog:
Github to Jira Bug Migration Script
Mar 09, 2011 @ 10:18:18

As part of a migration the Joind.in project made to track their bugs on a hosted Jira instance instead of the Issue Tracker on Github, Lorna Mitchell, one of the leads on the project has written up an import script she used to move current issues. The code is in her latest post.

I migrated only our open issues, and comments (and the comments ended up a bit weirdly formatted on the other end but this was the best they could do). It was nothing pretty or clever but in case it's useful to someone else.

The script connects to the github API and pulls down the information for the open issues including their titles, user and body of the issue. This is then used to make another connection for each to fetch their comments. The whole thing is dumped out to a CSV file that can be easily imported by the Jira team.

tagged: github jira import issue list bug migrate csv api


Lorna Mitchell's Blog:
3 Ways to Access a Namespaced PHP Class
Nov 29, 2010 @ 12:49:36

Lorna Mitchell has posted three different ways you can use to get access to a namespaced class in a PHP 5.3 application, all useful depending on where you are in the application and your needs.

After what felt like years of debate over the notation to use for PHP's namespaces, it seems like the feature itself has had relatively little use or attention since it was actually implemented in PHP 5.3. We're all used to working without it but using it does make code neater.

Her three options are:

  • Refer Namespace and Class Name
  • Import the Namespace
  • Alias the Namespace and/or Class

You can find out more about namespaces in PHP applications on the PHP manual.

tagged: namespace access method example import alias class


Import and export data using PHPExcel
Jul 15, 2010 @ 10:21:12

On the ThinkPHP blog today there's a new post looking at their experience with PHPExcel to open, modify, save, etc Microsoft Excel files directly from PHP.

EAR's Spreadsheet_Excel_Writer combined with the project Spreadsheet_Excel_Reader on SourceForge was a good helper in the past - but only for BIFF5. BIFF8 support in spreadsheet excel writer has been a problem for a long time, and according to the authors, is still somewhat kludgy in the current version. So I needed an alternative. After a short research I stumbled upon PHPExcel which supports reading and writing of many formats in one API.

He lists some of these input and output formats and includes a simple example of how to use the tool. He creates a basic Excel file with a few different attributes (title, body, keywords) and show how to read in a document to extract the document's content.

tagged: import phpexcel export tutorial excel microsoft


SitePoint Web Tech Blog:
Importing Content into Drupal
Apr 19, 2010 @ 11:23:22

On the SitePoint Web Tech blog there's a new post just for those looking to move their site(s) over to a Drupal installation - a quick technique for importing your information into a shiny new Drupal instance.

One of the most painful steps in any web system is importing content — especially so with Drupal. It is something that I have always dreaded. [...] That is all in the past. I am happy now. I recently discovered a module that is a crown jewel in the Drupal Contrib community — Feeds.

With the Feeds module you can directly pull the information in from the feeds your site already provides (or ones you could whip up quickly) and pull it directly into your new site - even CSV content will work.

tagged: drupal import content tutorial feeds module


Sameer Borate's Blog:
Simulating Packages in PHP
Nov 05, 2009 @ 07:52:20

Sameer Borate has a new post to his blog looking at the idea of simulating the idea of packages that several other languages have (like Java) with similar functionality to use them.

Most modern languages have a concept of packages, wherein related classes are stored together. PHP sadly doesn’t have a similar concept. [...] But in the spirit of 'programming into the language', what we can do is try to simulate a 'package-like' concept in PHP.

Wanting to stick with the "import()" function call, he's created a bit of sample code to mimic Java's loading method. The function more or less does what the auloading included in PHP can accomplish and he points out two issues with it - it doesn't really do a real "import" just an include and that, how it stands, you cannot tell what order the files will be included in (no sorting at all).

tagged: import package simulate tutorial


SitePoint PHP Blog:
How to Use PHP Namespaces (Parts 2 &3)
Jul 15, 2009 @ 08:16:24

The SitePoint PHP blog has posted the next two parts of their series looking at using namespaces in PHP - parts 2 and 3:

In the second part of the series they build on the basics and look at importing namespaces into a script, aliasing them to a shorter, easier to use name and some rules to consider about name resolution.

The third part of the series (the last part) looks at the keywords the namespace functionality uses and how to autoload namespaced classes to keep their namespacing intact.

tagged: autoload keyword alias import tutorial namespace


Rob Allen's Blog:
Zend Framework URL Rewriting in IIS7
May 12, 2009 @ 08:47:44

As a part of his work being done on the WinPHP Challenge, Rob Allen has done some work with routing and Microsoft's IIS7 web server.

I've already covered the Sqlsrv adapter, so let's look at rewriting requests with IIS7's URL Rewrite module. As with everything in IIS, you get at this tool via the IIS Manager GUI. Be aware though that the Url Rewrite icon is available at server level and at the website level.

The module allows you to define rules similar to mod_rewrite with Apache and even lets you import them from a current installation. The "Import Rules" panel lets you either specify a configuration file to pull from or lets you cut and paste the rules in for import (as seen here).

tagged: zendframework application microsoft iis7 modrewrite urlrewrite module import


Robert Basic's Blog:
LAMP and SVN on Ubuntu 8.10
Nov 25, 2008 @ 07:59:59

In this new post Robert Basic expands on an older post about installing LAMP on a Ubuntu system by tossing Subversion (SVN) into the mix.

This post is a rewrite of one of my older posts, Ubuntu as a dev machine, but this time I’ll explain also how to setup a basic SVN besides the LAMP. [...] Once again, I’m installing it under VirtualBox (VB).

He includes all of the apt-get commands you'll need as well as configuration options and commands to get your first project imported into subversion.

tagged: lamp ubuntu subversion svn aptget command configure import