Installing APC Manually

Pecl was giving me some problems so I needed to install APC for PHP manually. Pecl was compaining that apxs was not found during the config process, so I had to install it myself so that I could pass it the proper path.


wget http://pecl.php.net/get/APC-3.0.19.tgz
tar -xzf APC-3.0.19.tgz
cd APC*
phpize
./configure --enable-apc --enable-apc-mmap --with-apxs=/usr/local/apache2/bin/apxs
make
make install

Make sure you actually use your correct path to apxs. If apxs isn’t installed then you need to install the httpd-devel package, which usually works just fine through yum install httpd-devel

Then, just add the so path to your php ini and restart.


vi /usr/local/lib/php.ini
extension=apc.so

Then restart your server and should be done! Try running phpinfo(); to see if APC reports as installed and enabled.

PHP4 Support

Today marks the very last release of PHP4 declaring the old version officially dead. No matter what, PHP developers will now continue on PHP5 and 6, and many clients had some questions about how this affects projects.

  • Botsko.net will continue to support applications developed for php4.
  • Many previous projects will work properly if transferred to a PHP5 server.
  • All new applications/websites will be developed in PHP5 only.
  • We’re always available for reviewing code and planning upgrades.

Please contact us if you have any questions or concerns.

All Code Editors & IDEs Are Just OK

Over the last seven years I’ve tried out almost every single tool available for my code editing work. I’ve tried open source tools, free tools, commercial applications, and they none of them meet my expectations.

I wanted to quickly mention the top three I’ve been able to use the longest and still document why they’re not what I want them to be.

Coda

I’ve tried out the excellent editor from Panic – it has two killer features: ftp upload buttons next to filenames that are stored locally and sharing via bonjour over the network. Coda is pretty basic and lightweight, but for hardcore php developer it lacks tools I find helpful.

I’ve heard that Coda is working on subversion integration which will be nice, but what I really need is improved php support. If they wanted to give me better code analysis, php variable/function exploring functions, syntax error highlighting, etc, I would enjoy it much more.

Coda is unlikely to every meet all of those expectations because it’s more of an everything editor and will probably never have specific language features like that.

Zend Studio 5

I’ve used this tool the most but there are a few items it lacks that I really would like to have. First off, while it can edit files over ftp directly, I would like it to have an ftp upload like Coda does. Zend 5 has no subversion support. I’m really driven crazy by some basic file quirks on Mac that I’ve been unable to resolve.

Zend 6 has a lot more features that would be very useful but unfortunately, it’s a worse program for me than Zend 5.

Zend 6

Immediately I’m shown how awful and clunky the new project/file management system is. There are too many ways to create and store projects. Many of the default ways now store my code somewhere I don’t want it, and confused the heck out of me when trying to edit files.

It also decided to keep all of these hidden files in my folders which had I left them would have been checked into my subversion repo. I immediately dismisses Komodo from Aptana because of this same issue – my project files were being stored in with my code.

I’m having similar problems with zend 6 on mac – files will not open properly when I just double click on them or right click and select “open with”.

Also, the preferences are a thousand times more confusing – I can change syntax colors in two or three different places for the same code type.

Why can’t anyone fix these issues? Who would release a tool that can’t properly open files? Why does Zend have to make a product that’s actually worse than it’s predecessor? I’ve tried a thousand others but I’ll keep looking. Any suggestions?

Install Apache, MySQL, and PHP on OS X (10.5)

While I was at zendcon I needed to setup my macbook with a typical apache/php/mysql server, but I was unsatisfied with both the default server that apple included and with the install system provided by XAMPP. I’ve since setup a server on both my MacBook and my iMac.

In order to get support for mysql as well as tools necessary for compiling, you need to install the apple developer tools. Check your original mac disc as you may already have a copy.

Anyway, on with our install:

Apache

First, download the latest version of the apache httpd web server.

./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite

Then, run the standard make, sudo make install.

MySQL

Then download the latest mysql source file. Make sure you download the source “Compressed GNU TAR archive (tar.gz)” as we’ll need to custom compile it.

However, PHP5 no longer includes mysql shared libraries needed during the configure process. To get these, download the source file for the mysql version you just installed. Once downloaded, decompress it and run the following:

./configure --prefix=/usr/local/mysql --with-unix-socket-path=/usr/local/mysql/run/mysql_socket --with-mysqld-user=mysql --with-comment --with-debug

make

sudo make install

sudo /usr/local/mysql/bin/mysql_install_db --force

sudo mkdir /usr/local/mysql/run
sudo mkdir /usr/local/mysql/data

sudo chgrp -R mysql /usr/local/mysql

sudo chown -R mysql /usr/local/mysql/run /usr/local/mysql/var /usr/local/mysql/data

Then start the server with:

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

zlib

Then, install zlib if it’s not already installed on your system. Download zlib, and it should be a basic ./configure, make, sudo make install process.

Once zlib is installed, make sure you know the path as we’ll need it during the php configure process.

PHP

Next, download the latest php package. Decompress it, and now we’re ready to configure.

./configure --prefix=/usr/local/apache --enable-cli --with-mysql=/usr/local/mysql --with-zlib-dir=/usr/local --with-apxs2=/usr/local/apache/bin/apxs

Then, run make and sudo make install to complete the process.

Restart apache and test everything out. If php didn’t do it automatically, add in AddType application/x-httpd-php .php to your httpd.conf file – commonly located in /usr/local/apache/conf/httpd.conf.

Then, start your webserver.

sudo /usr/local/apache/bin/apachectl start

And finally, once everything is done you’ll want to setup your account to properly allow access to mysql and apache commands. Just run the following to add their paths to your bash profile:

echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
echo 'export PATH=/usr/local/apache/bin:$PATH' >> ~/.bash_profile

Tech-Tidbit: HTML Entity to Decimal Translation

It became necessary this week for me to find a way to convert html entities into their decimal equivalents. I’m not very fond of dealing with character encoding and entity issues but I was finally able to get things working. In the end we modified data within the database which meant I wouldn’t get to use this script, but it was a very nice find.

The nice thing about this is that it leaves any existing decimal-format characters alone, and properly translates html entities to the decimal format.

After searching the net for a while I found a piece of code that seemed like a good solution. The original needed a bit of cleanup and tweaking, but here it is:

function htmlentities2unicodeentities ($input) {
  $htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
  $entitiesDecoded = array_keys  (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
  $num = count ($entitiesDecoded);
  for ($u = 0; $u < $num; $u++) {
   $utf8Entities[$u] = '&#'.ord($entitiesDecoded[$u]).';';
  }
  return str_replace ($htmlEntities, $utf8Entities, $input);
}

You can test the translation with this:

$test_strs = array('K&#363;lob', 'K&oacute;pavogur');

foreach($test_strs as $test_str){

  print 'ORIGINAL: ' . $test_str . '<br />'."\n";
  print 'TRANSLATED: ' . entities_to_unicode($test_str) . '<p>'."\n";

}

If you’re interested in converting things the other way around, good luck. I’ve been searching around for a while and I just can’t seem to find anything that works well enough without using some long array to translate things. Let me know if you find one!

Tech-Tidbit: Smarty Variables

One of my recent projects was using Smarty – I found myself in a position where I needed to access a variable assigned to a Smarty template directly – I could not access it before/while it was being assigned and Smarty doesn’t provide enough resources to interact with it directly before it’s actually transferred to the template. Smarty does allow you to edit other variables by using the global command in php, but not those that have already been assigned.

What did I end up doing? I just accessed the Smarty template object itself.

$this->_tpl_vars['name_of_template_var_here'];

I had to perform some fairly fancy tests on that data. Then, if you want modify that data you can just save it back to the above variable or re-assign it:

$this->Assign("name_of_template_var_here", $new_value_here);