Tag: php
About
PHP is a reflective programming language originally designed for producing dynamic web pages. PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.
The main implementation is produced by The PHP Group and released under the PHP License. It is considered to be free software by the Free Software Foundation. This implementation serves to define a de facto standard for PHP, as there is no formal specification.
From en.wikipedia.org/wiki/Php
"Simplicity is prerequisite for reliability." - Edsger W. Dijkstra.
As our experience grows, we learn from past mistakes and discover what's truely important in reliable systems.
When designing systems, simplicity is an often heard mantra, but it isn't getting applied nearly as much as spoken off. I'm guilty of this too. I think it's mainly because engineers love to, well, engineer : ) and will naturally try to outsmart problems by throwing more tech at it.
This article in 50 words: I used to prefer spaces vs tabs, now I don't care so much, think it's
more important that you can easily switch on a per-project basis. Have some thoughts on how conventions
should be established, and I'll demonstrate bash code that can convert your codebase to a new standard.
.svg/200px-Coat_of_Arms_of_Switzerland_(Pantone).svg.png)
When I started this techblog in 2007 and got my first 500 visitors, I was in
the clouds. If you told me then I'd hit the 5,000,000 visitor milestone 3 years later,
I would have probably slapped some sense into you.
Not in my wildest dreams did I imagine my little side-project would take off like this.
Yet here we are.
To celebrate I wanted to give a prize to the exact 5th milion visitor, but all I know
is that he/she is from Swit...
Here the notes I took during the Dutch PHP conference 2010 (#dpc10). They're not a representative
summary of the event's highlights cause I could only attend 1 of 4 talks at any given time.
I also filtered out things that didn't interest me personally.
Don't know Redis? Think Memcache, with support for
for lists, and disk-based storage.
You can use Redis as a database, queue, cache server or all of those combined.
Let's see how you can use this power in your PHP apps.
I still got sites running Apache, but all new projects are launched with
Nginx. I don't need many of the features that Apache offers, and the speed
gain of Nginx is just tremendous. Once you've experienced it, I doubt you'll
want to go back.
At our company we have a lot of uses for a solid API. We can use it to
distribute config files, have servers report in, let customers edit DNS
records using their own interface, etc.
The core of our new project runs on Node.js. With Node you can write
very fast JavaScript programs serverside. It's pretty easy to install Node,
code your program, and run it. But how do you make it run nicely in the
background like a true server?
Hi. Have you met KvzHTML? It's a standalone PHP Class for generating HTML. It's been hiding deep inside the caverns of my secret GitHub repo: kvzlib - a collection of code snippets too small or unfinished to deserve their own repository. But I find working with this class so pleasant, I thought I'd share the fun.
PHP 5.3 is a big leap forward for PHP and brings of a lot of neat features.
However, big leaps can also mean big changes and potentially big breakage when
it comes to backwards compatibiltiy.
Looking back at a great CakeFest in Berlin, I learned a lot about CakePHP and met many nice and inspiring people. Here are some conference notes I took that where particularly useful or new to me.
IDs are often numbers. Unfortunately there are only 10 digits to work with,
so if you have a lot of records, IDs tend to get very lengthy. For
computers that's OK. But human beings like their IDs as short as possible.
So how can we make IDs shorter? Well, we could borrow characters from
the alphabet as have them pose as additional numbers....
Alphabet to the rescue!
Sometimes MySQL needs to work hard. I've been working on an import script that fires a lot of INSERTs. Normally our database server handles 1,000 inserts / sec. That wasn't enough. So I went looking for methods to improve the speed of MySQL inserts and was finally able to increase this number to 28,000 inserts per second. Checkout my late night benchmarking adventures.
If you've written a PEAR package, it's probably a good idea to submit some end user documentation. Here's how to do it.
So I've been learning CakePHP the last few days. Bit by bit I've been trying to port a lecagy admininistration app to Cake. 'Secretly' linking menuitems to finished Cake parts as we go. And I must say: I'm pretty excited. I did run into a disturbing conclusion though. I estimated the legacy app will have over 300 Models & Controllers once finished. That could easily add up to (300 x 4 =) 1200 views. And here I am, creating a maintenance hell while trying to solve one!
Everyone knows PHP can be used to create websites. But it can also be used
to create desktop applications and commandline tools. And now with a class
called System_Daemon, you can even create daemons using nothing but PHP.
And did I mention it was easy?
In another article I've told you about how I would like to see one rule removed from the PEAR Coding Standards. This rule would allow developers a bit more flexibility, while staying true to the convention.
Working with trees
When working with tree data structures you often need to craft them in different ways. PHP offers a lot of functions to change the shape of arrays, but often they only go 1 level deep. Trees can count an almost infinite number of levels. Hence we need recursive replacements for our beloved array & string functions.
Working with trees
When working with tree data structures you often need to craft them in different ways. PHP offers a lot of functions to change the shape of arrays, but often they only go 1 level deep. Trees can count an almost infinite number of levels. Hence we need recursive replacements for our beloved array functions.
Since a couple of months now, I've been involved with PEAR as a contributor. Contributing to PEAR means adhering to the PEAR Coding Standards. Their standards have actually been thought over, and using them for projects (also outside of PEAR), leads to consistency, and makes it easier for many developers to understand each other's code.
Code can be scanned and checked for conformity using the PHP CodeSniffer package.
It took me a while to get rid of my old cod...
In PHP, sessions can keep track of authenticated in users. They are an essential building block in today's websites with big communities and a lot of user activity. Without sessions, everyone would be an anonymous visitor.
In system terms, PHP sessions are little files, stored on the server's disk. But on high traffic sites, the disk I/O involved, and not being able to share sessions between multiple webservers make this default system far from ideal. This is how to enhance PHP session management in terms of performance and shareability.
Hello good people. Our little project is going strong and thanks to Felix Geisendörfer there are a couple of new developments that I want to share with you. I'll limit this article to SVN though.
Thanks to a lot of extra effort by Michael White (http://crestidg.com) there now is a namespaced version of PHP.JS available for your coding pleasure.
I tried to do some Image Magick with PHP recently on an Ubuntu Feisty machine, and even though I had the required package: 'php5-imagick' installed, and I updated my php.ini with imagick.so, I kept getting the error Class 'Imagick' not found. This is how I eventually fixed it.
Licensing
Since the project is really kicking off and we're almost at 100 ported functions, I thought it was probably time to think about licensing. So I did a little bit of research, and I think the MIT license might be what we're looking for.
Or: How to convert multipage TIFF to PDF in PHP.
Let's say you have a fax with multiple pages that has been stored as a TIFF and you want to convert it to PDF using PHP for digital document flow. In this article I will show you a tiff2pdf function for PHP, because it cannot be done directly with ImageMagick.
I recently faced a programming challenge that almost broke my brain. I needed to create a function that could explode any single-dimensional array into a full blown tree structure, based on the delimiters found in it's keys. Tricky part was size of the tree could be infinite. I called the function: explodeTree. And maybe it's best to first look at an example.
If you're like me and you're interested in the stats of your website or blog, you might also want to know how many Diggs all of your articles have received. But that can become quite a pain when you have more and more articles, pages or blog posts. So why not let PHP retrieve the Digg count of your articles so you can use it in graphs or other statistic tools?
Recently I've seen a lot of screencasts in the Planet Ubuntu RSS feed. A screencast is an embeded flash video of your desktop, often used in tutorials instead of screenshots. I wondered if I could make these online flash videos myself; turns out, it's pretty easy! So in this article I will cover how to install the video capturing tool, how to use it, how to convert the video to a flash video (flv) file, and finally how to embed a flash player in your site just like YouTube. Create your own screencasts in 5 easy steps!
Recently two of my articles reached the Digg frontpage at the same day. My web server isn't state of the art and it had to handle gigantic amounts of traffic. But still it served pages to visitors swiftly thanks to a lot of optimizations. This is how you can prevent heavy traffic from killing your server.
Not everyone knows about PHP's capabilities of making SSH connections and executing remote commands, but it can be very useful. I've been using it a lot in PHP CLI applications that I run from cronjobs, but initially it was a pain to get it to work. The PHP manual on Secure Shell2 Functions is not very practicle or thorough for that matter, so I would like to share my knowledge in this how to, to make it a little less time consuming setting this up.
Last friday, PHP announced the end of life of version 4 of their popuplair scripting language.
You want your website to be as safe as possible. So you'll typically want Open Basedir and Safe Mode to be on. When you're in a shared hosting environment, you'll find that any server administrator with a good sense of security will also have these restrictions in place. However security pretty much always limits functionality and this case is no different. Because what if you are caged in a restricted environment, and you would still like to use shared libraries like the ones provided by PEAR?
I ran accross php value, php flag, php admin value and php admin flag in a couple of .htaccess files, and I've used them sometimes as well by just pasting an example, but I've never really understood why there was such a great diversity. Couldn't php_setting X Y just handle it, and if not, what do the admin, value and flag attributes mean?