Grep/Find all php short tags
grep -rn "<?[^p]" *
grep -rn "<?[^p]" *
I had a problem upgrading to phpStorm 3.0. Needed to kill the project data, for phpStorm to reset.
$> rm -rf .idea
to clear the project data.
I have a requirement to not serve SVN meta data with the project, once deployed on a server.
So what can I do?
Prevent Apache from serving the content:
Put an apache directive:
&amp;lt;DirectoryMatch .*\.svn/.*&amp;gt; Deny From All &amp;lt;/DirectoryMatch&amp;gt;
or:
Remove all the SVN metadata altogether
While in the *nix prompt:
find . -name ".svn" -type d -exec rm -rf {} \;
Took me a while to find out how to do this… as there was no good examples on the web.
So, here it is… so I can find it again.
keywords:
db database transaction rollback commit magento zend.
try {
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$write->beginTransaction();
// do stuff here
$write->commit();
} catch (Exception $e) {
mage::log(__METHOD__ . ':' . __LINE__ . ': Rollback happened.');
$write->rollback();
}
Please drop a line if you found this useful. Thanks!
ls -tr | tail -n 1
I always forget these commands… so I’m posting it here, so I can find them again easily.
Getting a value out of a loaded yaml config file.
[project root]/app/frontend/config/app.yml
all:
.general:
api_key: ASDFASDFASDFASDF
sfConfig::get(‘app_api_key’);
will return “ASDFASDFASDFASDF”;
I’m assuming you have a fresh install of centos 5.5.
$> yum groupinstall "Development Tools"
$> wget http://us.php.net/get/php-5.3.3.tar.bz2/from/www.php.net/mirror
$> tar xvf php-5.3.3.tar.bz2
$> yum install mysql-server httpd-devel-* libxml2-devel-* openssl-devel* xmlsec1-openssl-devel-* libpng* libjpeg* curl-devel libmcrypt* mysql-devel* mysql.*
$> cd php-5.3.3
$> ./configure --with-mysql=shared --with-openssl --enable-pdo --with-pdo-mysql=shared --with-mhash=shared --enable-soap=shared --with-config-file-path=/etc/ --with-apxs2 --with-mysqli --enable-zip --enable-shared --with-curl --enable-mbstring=all --enable-maintainer-zts --with-jpeg-dir=/usr/lib/ --with-libdir=lib64 --enable-soap --with-pdo-mysql --with-gd --with-mcrypt
$> make; make install;
$> service httpd restart
and there you go… php 5.3.3 on the box…
[are/did] you:
1.) backed up the file
2.) backed up the RIGHT file
3.) editing the right file
4.) editing the right file on the right server/environment
5.) are you viewing cached data, or live?
6.) does the input/output validate?
7.) did you remove all exit/die statements?
If someone else looked at it, how many WTF per minute will there be?
As a web developer, you have to deal with web forms. Why would you make a new form, and an edit form, which is basically the same.
How to handle this would be to use this design pattern:
1.) load the get item to load, if it exists. Lets call it $dataObject
2.) if $dataObject is empty/does not exist, start a new dataObject. Lets call it $dataObject
3.) dataObject is now instantiated.
4.) Do what needs to be done — for example “title” of the page, being “editing XXX”, or “new dataObject”. Whatever frontend reflections need to happen, based on if it’s new object or editing an old object.
5.) populate the form, accordingly. If the object is blank, it’ll just be populated with the default values.
6.) onSubmit()… check to see if an ID value was submitted, and the appropriate security checks, and deal accordingly. If there was no ID value, start a new dataObject, to be populated with the data submitted.
7.) $dataObject->save();
The above described is how symfony admin generator handles form reuse. While the admin generator is useful for most cases, sometimes you need to just do “more” customizations, than using the generator.
For example, you need to handle a collection of both NEW and Prior saved objects… to do batch edits, it’s easier to do it manually, instead of using the symfony-admin-generator.