The Dev Pages

A knowledge base for simple (and beyond) web applications development

Archive for August, 2009




I absolutely hate the new project dialog in eclipse. It seems like each plugin (PHP, Flex, Aptana, SVN, etc.) has its own way of doing a new project.

Here’s one reason I hate these dialogs – If I want to add a new project into my workspace, I can’t put the files there first and then make it a project. Why would I want to do this? 1)I want to clone a git project from a remote repository into my workspace. Right now there is no way to do this with an add project dialog. So the files get to my workspace, but they don’t show up as a project. Same goes for SVN stuff where I want to re-add the files as a new project without having to check the whole stinking repository out again. Plus, it would be nice if I wanted to add files first, then make projects. Is that so hard? I understand eclipse doesn’t want to muck around in a folder with no project data to make a new project, but really, is it so hard to make a non-project folder a project folder? And if eclipse isn’t meant to do this, GET RID OF THE ‘Create project from existing source’ option because it doesn’t work with many project types.

So here is a way I found that works swimmingly. I wonder if this came as an option with a plugin. If so, I am using PDT php, Aptana, Subclipse, and I think those are the main ones. If you don’t get this option in your menu, than who knows what plugin you may need. I’m just glad I got it to work for me.

SOLUTION: Screw the new project dialog. Do File->import then select the folder ‘Other’->Existing Folder as New Project. This works great for my goal of 1)having files in my workspace that are not a project in eclipse and then making that folder and all its files a new project.




When doing a push to master I was getting

bash: git-upload-pack: command not found
bash: git-receive-pack: command not found

The skinny: The path on your remote machine is not correct, at least the path being used for non-interactive shell logins. Most likely, updating the .bashrc of the remote user, (the user in the command) will fix your problem. Note that nothing on the client side of things really matters except that you have git-core installed and you may save a path to git-upload-pack in your local git settings if you wanted to.

Hoo boy, I have updated this after a not-so-fun experience with bluehost, ssh, bash, and git. After getting my ass kicked for two hours, turns out that my hosting issued some ssh updates that made it so no .bashrc or .bash_profile settings were being used for setting the path on shell logins and commands. Very nice.

Fix your path

Key 1: Figure out where the binaries for git are on the remote system. On my lame-o shared server they were in /home/<myusername>/local/bin. The folder will have a bunch of programs, or at least git, gitk, git-shell, git-upload-pack, etc.
Key 2: Make sure the path for your non-interactive shell login contains the folder where your git binaries are located. This following command, from the stackoverflow post, is awesome for seeing the ‘non-interactive shell’ path. Matt Curtis is great.

ssh you@remotemachine echo \$PATH

So if the result of ssh you@remotemachine echo \$PATH does not contain the folder where your git binaries are located, this is the source of the problem.

On the remote machine, login to the user being used for the git command, and make sure the .bashrc file sets the path correctly. You may not even need to add anything, but if you are reading this post chances are you need to include

export PATH=$PATH:/<pathtoyourgitbinaries>

in your .bashrc.

For all of us who didn’t immediately grasp what a ‘non-interactive shell login’ is, it goes as follows. When you login to a linux machine over ssh or at a desktop, this is an ‘interactive’ shell session, and loads the settings for the shell from .bash_profile in the home folder of the user who us logged in.

If you are simply issuing commands without logging in (like git clone, ssh somecommand, etc., or I guess just opening a bunch of shells in an os) then you are using a ‘non-interactive’ shell session. This will load settings from the .bashrc in the home folder of the user who us logged in.

A lot of times systems will have the .bash_profile call the .bashrc, so most relevant settings can go in the .bashrc.

But the difference in interactivity is why logging into an ssh session and doing echo $PATH will display a different path then issuing a non-interactive command like ssh you@remotemachine echo \$PATH.

Alternately, explicitly state the path to the git-upload-pack binary

If you can’t get the path settings in your (remote) .bashrc to work, you can tell git exactly where to look for the git-upload-pack binary. So bluehost users, or anyone else who has no control over the path setting for shells, you can explicitly use the –upload-pack option to explicitly set the path to the git-upload-pack binary you want. Example (Note that the upload-pack is an option with 2 hyphens -andanother- ):

git clone –upload-pack /home/<username>/bin/git-upload-pack <username>@<yourdomain>:/home/<username>/gitprojects/agitproject.git

If you have a git user for bare remote repos it will probably look like:

git clone –upload-pack /<somepathtoyourgitbinaries>/git-upload-pack git@<yourdomain>:agitproject.git

You can also add the server paths to your local git config

receivepack = /home/<myusername>/local/bin/git-receive-pack
uploadpack = /home/<myusername>/local/bin/git-upload-pack

where the config file is in the .git directory of my project on local. This line is under the entry for the remote I had set up called ‘origin’ (use the path on the server where the git install is located and make sure git-receive-pack is in there on the server).

Bluehost users getting the git-upload-pack: command not found error, or similar command not found errors can see the explanation of why you can’t control your .bashrc at http://66.147.243.109/index.php/kb/article/000572

See http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly

make[2]: execvp: Permission denied


Posted on August - 30 - 2009



make[2]: execvp: true: Permission denied

You need to do chmod 755 true on the true script on your bin, For me I had followed the instructions at:

http://blogs.koolwal.net/2009/07/20/howto-installing-git-on-bluehost-domain-hosted-websites/

for installing git on bluehost. I had to make a script called ‘true’, and put it in my local bin to get git to compile.

make[2]: execvp: <YOUR FILE HERE>: Permission denied

These errors mean that your script does not have execute rights. You can ‘chmod 755 <YOUR FILE>’ and it should work.




Getting an HTTP_Request class was pissing me off. So it seems like you can’t install PECL classes on your php install because of rights issues on a shared hosting environment.

BUT, you can get PEAR classes installed through the cPanel, using the PHP PEAR Packages link. I was adding the HTTP_Request package (HTTP_Request2 won’t install because there is no stable release as of yet).

But even after the install, the classes could not be found. Like when I did require_once(’HTTP/Request.php’) I was getting the classic not found warning and error:

Warning: include(HTTP/Request.php) [function.include]: failed to open stream: No such file or directory
Warning: include() [function.include]: Failed opening ‘HTTP/Request.php’ for inclusion
Fatal error: Class ‘HTTP_Request’ not found

You have to edit the php.ini (or ini_set the include_path ) to include :/home/yourusername/php, or in my case the home directory is now home3 for some reason, with some weird aliasing allowing for home I think. The PEAR packages install to /home/yourusername/php, so this needs to be added to the include path.

If you still get:
PHP Fatal error:  main(): Failed opening required ‘PEAR.php’
Then your include_path may be missing :/usr/lib/php, this is the main (not your local user) php lib folder that, I think, has the main PEAR files (The ones that your local PEAR package installs like HTTP_Request will be calling). So when you install a PEAR package via the cPanel, it puts them in /home/yourusername/php, and those files will need to know about the main PEAR install in /usr/lib/php by having /usr/lib/php in the include path.




private function XMLtoHTMLEntities($string){
//get rid of any XML entity encoding that may have been applied (like in an RSS feed)
$unXMLEntify = str_replace ( array ( '&amp;' , '&quot;', '&apos;' , '&lt;' , '&gt;'), ->
array ( '&', '"', "'", '<', '>') , $string );
return htmlentities($unXMLEntify);
}

phpunit: command not found


Posted on August - 4 - 2009



phpunit: command not found

Your phpunit file needs execute access and has to be in a ‘bin’ folder (/usr/bin or usr/local/bin)

How to install the pdo myql drivers for php


Posted on August - 3 - 2009



First install pdo.

I already had php 5 with the pdo extension included in the build. But I needed the mysql driver for the php extension since it only came with 2 (sqlLite, sqlLite2).

To add the mysql driver for pdo in your php install, put (pdo_mysql.so – you’ll have to compile this) in your extensions directory and then enable that extension in php.ini. WTF, pretty simple but there are no web pages with instructions. And compiling in Mac OS X sucks because you need to install extra Developer tools and than run the command line compile commands.

http://pecl.php.net/package/PDO_MYSQL