14 Replies - 8358 Views - Last Post: 24 July 2013 - 02:37 PM

#1 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1469
  • View blog
  • Posts: 8,173
  • Joined: 07-September 06

Extensions: Which ones do you use/ what have you made?

Post icon  Posted 07 July 2013 - 08:47 PM

The title pretty much says it all, but what extensions do you normally install with your PHP setup (assuming you are using something that isn't installed by default)?

Have you ever written a PHP extension? If so, what was its purpose?

The reason I ask is that I am currently working on an extension that brings templating a little closer to the easy side of things to do, and am wondering what others have done in the area of PHP extensions in the past. Basically it acts like PDO where you set up placeholders (?s) in a block of text (or HTML, Javascript, CSS, etc.) then prepare that string for use, bind parameters (bind_params -- along with providing a format string for datatypes and the output format of variables) to it, and fetch the resulting string. It takes after PDO in that it does type verification for you, allows you to change variables' values and fetch again without needing to re-bind, and is written in C (thus allowing for faster execution than a PHP-based counterpart).

Is This A Good Question/Topic? 3
  • +

Replies To: Extensions: Which ones do you use/ what have you made?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4123
  • View blog
  • Posts: 13,011
  • Joined: 08-June 10

Re: Extensions: Which ones do you use/ what have you made?

Posted 07 July 2013 - 10:45 PM

Quote

what extensions do you normally install with your PHP setup (assuming you are using something that isn't installed by default)?

it depends on the setup. the windows machine is pretty much fixed (XAMPP), on my Mac I can install extensions as I go (thanks to MacPorts). so besides the Suhosin patch, thereís probably PDO-MySQL, mbstring, iconv from the beginning.


Quote

Have you ever written a PHP extension?

nope, canít code in C(++).
Was This Post Helpful? 0
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: Extensions: Which ones do you use/ what have you made?

Posted 07 July 2013 - 11:16 PM

I mostly just require PDO extensions, though I have used the FileInfo extension. I'm contemplating using the BBCode extension, though I already have some custom code for BBCode parsing, and I'm also considering memcached, though I have to look into whether or not it can store arrays and objects.

I've never thought about making an extension, mostly because I can't code in any C language.
Was This Post Helpful? 0
  • +
  • -

#4 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 463
  • View blog
  • Posts: 820
  • Joined: 17-June 08

Re: Extensions: Which ones do you use/ what have you made?

Posted 09 July 2013 - 10:11 AM

View PostBetaWar, on 07 July 2013 - 11:47 PM, said:

...what extensions do you normally install with your PHP setup (assuming you are using something that isn't installed by default)?

Whatever ones I need. :) But seriously, I don't have a list of "essential" extensions or anything like that. I just install the ones that are required for the problems at hand. Usually things like PDO drivers, fileinfo, and memcached, though it varies with what I'm working on.

Quote

Have you ever written a PHP extension?

Nope. I do know C, but I've never had a reason to write one. Generally, for things that I can't do in pure PHP, either there's already an extension for it or shelling out to an external executable is easier. Why make things more complex than they need to be?


View Poste_i_pi, on 08 July 2013 - 02:16 AM, said:

...I'm also considering memcached, though I have to look into whether or not it can store arrays and objects.

It can. Theoretically, memcached can store anything that's serializable. Usually, though, I just stick with arrays. Less cache bloat and no need to worry about custom serialization for complex objects.
Was This Post Helpful? 1
  • +
  • -

#5 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Extensions: Which ones do you use/ what have you made?

Posted 09 July 2013 - 10:36 AM

There are only really two, non-standard extensions I would consider "essential".
On development setups: XDebug.
On both development and production setups: APC.

Aside from the performance benefits of APC, it even has in-memory key-value storage capabilities, much like Memcache, except on a more local scale. (It's not attached to a server.)
Was This Post Helpful? 1
  • +
  • -

#6 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: Extensions: Which ones do you use/ what have you made?

Posted 09 July 2013 - 02:31 PM

I haven't looked into APC yet. Does it really bring the 2-7x sweet lovin' performance improvement it promises?
Was This Post Helpful? 0
  • +
  • -

#7 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Extensions: Which ones do you use/ what have you made?

Posted 09 July 2013 - 03:37 PM

I haven't done any benchmarks, but when working with large frameworks like Symfony, just the addition of APC makes a very noticeable difference in page load speeds. The more code there is to be interpreted per request, the more of a difference it will make.
Was This Post Helpful? 0
  • +
  • -

#8 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1469
  • View blog
  • Posts: 8,173
  • Joined: 07-September 06

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 10:44 AM

For anyone who is interested I just pushed alpha version 0.1 of Temple (a fast and easy templating engine) to my github. It is built for 32-bit Fedora 18 if you have one of those laying around. In the future, depending on interest, I may release other builds (OS/Architecture) or I may just open-source the project.
Was This Post Helpful? 0
  • +
  • -

#9 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6333
  • View blog
  • Posts: 25,530
  • Joined: 12-December 12

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 11:00 AM

View PostAtli, on 09 July 2013 - 10:37 PM, said:

I haven't done any benchmarks, but when working with large frameworks like Symfony, just the addition of APC makes a very noticeable difference in page load speeds. The more code there is to be interpreted per request, the more of a difference it will make.

APC - Armoured Personnel Carrier?

Perhaps, Alternative PHP Cache; like a compiled version of PHP?

This post has been edited by andrewsw: 14 July 2013 - 11:03 AM

Was This Post Helpful? 0
  • +
  • -

#10 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6245
  • View blog
  • Posts: 24,013
  • Joined: 23-August 08

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 11:12 AM

My first exposure to PHP (PHP 3, in fact; at one point had to port to 4.0), was writing extensions for it for an in-house project, so I had to learn PHP to test prior to releasing the API to the web developer. Had to do similar for Python for a QA smoke-testing suite.

As others have said, I use whatever's necessary for the task at hand. A previous position required SOAP interaction (blech), so we used SOAPClient extensively (I wrote the SOAP server in C). Currently in heavy-duty CakePHP framework development, so not using so many extensions directly.
Was This Post Helpful? 0
  • +
  • -

#11 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 11:39 AM

View Postandrewsw, on 14 July 2013 - 06:00 PM, said:

View PostAtli, on 09 July 2013 - 10:37 PM, said:

I haven't done any benchmarks, but when working with large frameworks like Symfony, just the addition of APC makes a very noticeable difference in page load speeds. The more code there is to be interpreted per request, the more of a difference it will make.

APC - Armoured Personnel Carrier?

Yes. Military hardware. Always does wonders for page load speeds.

Seriously though: Alternative PHP Cache.

php.net/apc said:

The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.


View PostBetaWar, on 14 July 2013 - 05:44 PM, said:

For anyone who is interested I just pushed alpha version 0.1 of Temple (a fast and easy templating engine) to my github. It is built for 32-bit Fedora 18 if you have one of those laying around. In the future, depending on interest, I may release other builds (OS/Architecture) or I may just open-source the project.

Looks interesting. Unfortunately not running Fedora, and it doesn't seem to run under Ubuntu. (I tried :))
Was This Post Helpful? 1
  • +
  • -

#12 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6333
  • View blog
  • Posts: 25,530
  • Joined: 12-December 12

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 11:42 AM

Thank you @Atli. I don't know much about this, obviously, but:

Quote

just the addition of APC makes a very noticeable difference in page load speeds

and the goal of APC for "caching and optimizing PHP intermediate code" is confusing me?

[Apologies for taking this slightly off-topic.]
Was This Post Helpful? 0
  • +
  • -

#13 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 11:53 AM

Essentially, this is what the PHP interpreter normal does when executing:
Parse PHP file.
Compile into executable "opcode" (or intermediate code, as they call it.)
Execute the opcode


With APC (and other opcode caches):
IF opcode does not exist in cache:
    Parse PHP file.
    Compile into executable "opcode".
    Add opcode to cache.
ENDIF
Execute the "opcode" from cache.


The overhead of parsing and compiling the PHP code into executable opcode is bypassed with extensions like APC, which can make a significant difference where there is a lot of code to process.
Was This Post Helpful? 1
  • +
  • -

#14 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1469
  • View blog
  • Posts: 8,173
  • Joined: 07-September 06

Re: Extensions: Which ones do you use/ what have you made?

Posted 14 July 2013 - 08:47 PM

Alti, when I get a chance I'll compile it for Ubuntu and upload the installation guide/ library for you to try.
Was This Post Helpful? 0
  • +
  • -

#15 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1469
  • View blog
  • Posts: 8,173
  • Joined: 07-September 06

Re: Extensions: Which ones do you use/ what have you made?

Posted 24 July 2013 - 02:37 PM

I added an Ubuntu 12.04 LTS build of temple last night.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1