You may find these articles interesting: http://www.nolo.com/legal-encyclopedia/article-29953.html http://www.bitlaw.com/copyright/ownership.html
If you were an employee on a W2 then this wouldn't be an issue -- your work would be a "Work For Hire" by default.
Your boss has created a legally perilous situation for himself. If you're a contractor, then he likely doesn't own the software he thinks he does. If you're an employee, then he owes a lot of taxes.
So if you're ready to burn a bridge, here's an idea. Find an attorney who will take your matter on contingency -- many will do a no-fee consult to see if there's a case. What you want to do is license your code to your former boss (the code he thinks he owns already) for a reasonable but substantial one-time sum. Low to mid five figures doesn't seem unreasonable to me.
And as everyone else has said, find a new job. If you're looking for contract work and you know CodeIgniter, email me (in my profile).