Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Quickly download the PEAR libraries

To get a headstart for your website you can use the PEAR libraries. The following script downloads a couple of the most handy libraries, and also adds some symbolic links to the newly downloaded files.

#!/bin/bash
pear config-create $HOME $HOME/.pearrc
pear config-set php_dir $HOME/pear/lib

pear install -a PEAR

pear channel-update pear.php.net
pear install -a DB Mail
pear install -o Auth Auth_SASL Cache_Lite File
pear install -o HTML_QuickForm HTML_TreeMenu
pear install -o HTTP HTTP_Request
pear install -o Mail_Mime
pear install -o Log Pager
pear install -o Translation2-beta XML_Serializer-beta

ln -s ~/pear/pear ~/bin/pear
ln -s ~/pear/peardev ~/bin/peardev
ln -s ~/pear/pecl ~/bin/pecl

Replace old style PHP tags to new style tags

Sometimes you have to work with scripts that contain old-style PHP tags. This little snippets fixes those scripts, so they use the new style PHP tags.

find * -type f -exec perl -i -wpe 's/<\?php/<\?/g' {} \;
find * -type f -exec perl -i -wpe 's/<\?/<\?php/g' {} \;

Check the syntax of a bunch of PHP files all at once

Will find all files ending with 'php' and execute the syntax check of php for every found file. Useful if you quickly want to see which php file contains a parse error.

find ./ -type f -name \*.php -exec php -l {} \;
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS