Zend Framework has this "Run" button… this works on individual php files. but i am curious how would this work if you are using Zend Framework (or others) where everything (requests, etc) must go through the bootstrap file first before the actual file you are editing is executed?
R – Zend Studio + Zend Framework
zend-frameworkzend-studio
Related Solutions
The line from application.ini
resources.layout[] =
is equivalent to:
_initLayout() {}
in Bootstrap.php
Both of them are initializing new object, and this object is set as a bootstrap
param, which is a container for some application resources (values returned by _init
methods).
There are executed one by one, so to ensure one resource is initialized before the the current one, you force the order, using:
_initSomeResource() {
$this->bootstrap('otherResource');
// ..
return $someValue;
}
_initOtherResource() {
// ..
}
So the order of instantiating of the resources is:
otherResource
someResource
Now, you may also use:
$bootstrap->getParam('someResource'); // returns $someValue
Note, that you may encounter Circular Dependency
error, when you try to execute each other before each one.
You may use as many _init
methods you need, but to make them reusable, you may separate them to their own class, implementing Zend_Application_Resource_Abstract
class.
There are some out of the box application resources, which you may find in Zend/Application/Resource
directory. These are the resources, you are refering from application.ini
, i.e.:
resources.view.encoding = "utf-8" ; in application.ini
Zend/Application/Resource/View.php (path to the resource class)
Zend_Application_Resource_View::setEncoding('UTF-8'); // equivalent pseudocode
Hope it's more clear now.
I would say that you have a problem connecting from PHP to MySQL...
Something like PHP trying to find some socket file, and not finding it, maybe ?
(I've had this problem a couple of times -- not sure the error I got was exactly this one, though)
If you are running some Linux-based system, there should be a my.cnf
file somewhere, that is used to configure MySQL -- on my Ubuntu, it's in /etc/mysql/
.
In this file, there might be something like this :
socket = /var/run/mysqld/mysqld.sock
PHP need to use the same file -- and, depending on your distribution, the default file might not be the same as the one that MySQL uses.
In this case, adding these lines to your php.ini
file might help :
mysql.default_socket = /var/run/mysqld/mysqld.sock
mysqli.default_socket = /var/run/mysqld/mysqld.sock
pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock
(You'll need to restart Apache so the modification to php.ini
is taken into account)
The last one should be enough for PDO, which is used by Zend Framework -- but the two previous ones will not do any harm, and can be useful for other applications.
If this doesn't help : can you connect to your database using PDO, in another script, that's totally independant of Zend Framework ?
i.e. does something like this work (quoting) :
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
If no, the problem is definitly not with ZF, and is a configuration / installation problem of PHP.
If yes... Well, it means you have a problem with ZF, and you'll need to give us more informations about your setup (like your DSN, for instance ? )
Best Answer
Right click on your public/index.php file Choose "run as php web page" It will ask you what URL you want to view while it profiles index.php You can specify whatever url, but Zend requires that 'index.php' be in the url. This is okay, though, because the rest of Zend Framework will ignore it.
For example, if you want to profile: http://www.mydomain.com/accounts/view
you would simply type in: http://www.mydomain.com/index.php/accounts/view
Then you can watch the Zend Studio profiler go to work :)
I figured this out by watching Zend's product screencasts, here: http://www.zend.com/en/products/studio/videos