Tag Archives: php

Setting up xdebug on Zend Server CE on Mac OSX with Symfony 2 framework

Hi symfonians,

I think you probably finding for a solution how to install and use xdebug on Zend Server CE on your Mac OSX like me.

XDebug

First of all, to say, Mac OSX (snow leopard), Zend Server CE and Symfony 2 didn’t well matched built to work together.

At least, not perfect instantly.

So, if you want to work on those tools, you have to tweak a little bit of your tool to make it works together.

As Zend Server CE came with its own debugger, Zend Debugger, but someone prefer to use xdebug instead of Zend Debugger as the same as me.

Here are the steps how to make xdebug work on Zend Server CE on Mac OSX with Symfony 2.

  • Open Zend Server page, http://localhost:10081/
  • Disable “Zend Debugger”
  • Download xdebug.so binary which I suggest to download at -> http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging
  • Extract the archive and browse into ’5.3′ folder then copy ‘xdebug.so’ to ‘/usr/local/zend/lib/php_extensions’
  • Open ‘/usr/local/zend/etc/php.ini’ and add the following lines above [zend] section
zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
xdebug.show_local_vars=On
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
  • Now restart your Zend Server by ‘sudo /usr/local/zend/bin/zendctl.sh stop’ and ‘sudo /usr/local/zend/bin/zendctl.sh start’
  • You should be able to work with xdebug now!

To work with xdebug, I personally love the way by JetBrain’s PhpStorm with their bookmarklet generator, very useful tool.

Hope this help,

Seree

Symfony 2 Error – “Class ‘ResourceBundle’ Not Found”

Hi friends,

Just want to post a quick note here to be a troubleshooting guide for my team, I’m getting an error when trying to use CountryType (a dropdown list with country name display and country code as a value).

Got an error like this “Class ‘ResourceBundle’ not found”.

The solution to this issue is just install and enable intl extension for PHP.

As I’m using wamp, it is very easy for me just point and click to enable intl and it will works like a charm.

For CountryType, it is surprising me as it is easier than Ruby gems to have a country dropdown list in my web application.

Cheers,

Doctrine Error on Mac OSX – “It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.”

If you are working on Symfony 2 with Doctrine and getting stuck on “php app/console doctrine:schema:create” with this error…

Doctrine

DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or
the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead

You probably came to the right place!

If you are using MAMP same as me, just modify MAMP’s php.ini file is not enough to fix this error because when you execute php on the terminal, it uses the php from Mac OSX, not the one that came with MAMP.

So, the solution is to create new php.ini file in /private/etc directory with this content inside.


date.timezone = "UTC"

This will do the trick!

Doctrine

Doctrine Create Database Error – “No such file or directory”

As I’m working with Symfony 2 with Doctrine as an ORM and using MySQL as a database.

Symfony

I found this error when trying to create a database using the command “php app/console doctrine:database:create”.

I got “No such file or directory” error message.

After researched, I’ve found that my MAMP is missing one thing…

MAMP

When Doctrine is trying to create a new database, it is finding a ‘/var/mysql/mysql.sock’ which never exists in my system after MAMP installed.

So, the solution is to create a symbolic link to where the actual mysql.sock stay with this command…

“cd /var”

“sudo mkdir mysql”

“cd mysql”

“ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock”

Then try to run “php app/console doctrine:database:create” again.

It will works! :)

UPDATED:

If you are using Zend Server, you probably found the same error, just do the same but create a symbolic link to “/usr/local/zend/mysql/tmp/mysql.sock” instead of MAMP’s. :)

Symfony

What You Might Forget When Running Symfony Application at The First Time And Got Error!

I believe almost every newbies to Symfony 2 (one of the best PHP framework) is getting this error at the very first time they try to install Symfony 2 into their web directory and browse it.

I also got this error 3-4 times and doubt what’s wrong with it at the starting of project.

Here is what I have done when starting a new project.

  • Copy ‘symfony’ folder into my project folder.
  • Initialize Git using “git init”, “git add” and create “git remove” then “git commit” as the initial commit.
  • Configure httpd(.)conf of apache to create new virtual server at another port, then point the DocumentRoot to ‘symfony/web’ directory.
  • Browse it and BANG! got an error!

Well, if you are facing the same thing with me, you probably 99.99% forget a necessary step like me.

It is…

You forget to execute the vendors(.)php while will download required bundles for your symfony application.

Just bring up a command prompt and execute the command “php symfony/bin/vendors(.)php” and wait for a few minutes and browse your application again.

Yes, it will works now. :)