u/omerida
In this archive from May 2011 to Nov 2026
- 16
- posts
- 477
- comments
- 3
- media
- 1.7k
- score
Top posts
PHP Toolbox - a curated list of useful project resources, libraries, APIs
php-toolbox.comCodeClimate has Open Sourced its tools - free to use too.
blog.codeclimate.com/blog/2015/06/19/code-climat...Not downloaded yet
PHP Performance I: Everything You Need to Know About OpCode Caches : Engine Yard Developer Center
support.cloud.engineyard.com/entries/26902267-PH...A look at the internal implementaion of PHP objects and classes
jpauli.github.io/2015/03/24/zoom-on-php-objects....Not downloaded yet
No. we tried this with PEAR and it was awful. If you have a CLI application you use and wand to share, package it up as a PHAR file.
Stop using mysql_ functions, they're deprecated. Most developers use PDO or mysqli, each has its strengths.
Use prepared statements to prevens SQL injection attacks. Both PDO and mysqli can do this.
Document your methods using phpdoc standard, you can then generate documentation and your IDE will be more useful.
If your DB calls error, and log the message in your error handler, does the rest of your method still execute? Seems if there's an issue in one query, the rest of the code shouldn't execute.
I think returning an error code is frowned upon (-1, -2), seems this might be a case where throwing an exception (ExpiredPromoCodeException for example) would be better. At least, make the return codes class constants, so that calling code does:
$redeem = $this->RedeemPromotionalCode('12345', 'Freebie);
switch ($redeem) { case CouponClass::expiredCode: // handle expired code break; case CouponClass::invalidCode: // handle invalid code break; }
Your method does a lot, consider breaking it up into smaller methods that each do one thing. One to test if the code is valid, another to test if its expired, another method to write the usage details.
You should wrap all the writes to the database into a database transaction that you can rollback if any insert fails. http://php.net/manual/en/pdo.transactions.php
The logo is of a conductor
As others have said, the client doesn't need to be involved in your decision to use version control. Its a tool of the trade, and ideally you'd steer away from devs who don' t use version control
Now, if the issue is that they don't want to install git/svn/whatever so that you can deploy from VC, then that's their choice. You still have SSH to deploy via, right? Though, I suspect w/this client it's more likely FTP?