By Korvin Szanto
Composer handles all autoloading simply by including a single generated PHP file.
<?php
require "./vendor/autoload.php";
{
"require": {
"monolog/monolog": "1.0.*"
},
"autoload": {
"psr-4": {
"Vendor\\Package\\": "src/"
}
}
}
Do not rush into starting an open source project
Another project probably already solved it better. If you find one, consider contributing instead of reinventing the wheel.
http://choosealicense.com/
http://choosealicense.com/
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
Closed source is cool too I guess, composer lets you provide "proprietary" for your license.
<?php
(!is_numeric($input['sat_math']) && ($input['sat_math'] != "")) ? ($errors[] = "Your SAT math must be a numeric value, or blank.") : ('');
(!is_numeric($input['sat_verb']) && ($input['sat_verb'] != "")) ? ($errors[] = "Your SAT verbal must be a numeric value, or blank.") : ('');
(!is_numeric($input['sat_writ']) && ($input['sat_writ'] != "")) ? ($errors[] = "Your SAT writing must be a numeric value, or blank.") : ('');
((($input['act'] > 36) || ($input['act'] < 1)) && ($input['act'] != "")) ? ($errors[] = "Your ACT score is out of the valid range.") : ('');
((($input['act_eng'] > 36) || ($input['act_eng'] < 1)) && ($input['act_eng'] != "")) ? ($errors[] = "Your ACT English score is out of the valid range.") : ('');
((($input['act_math'] > 36) || ($input['act_math'] < 1)) && ($input['act_math'] != "")) ? ($errors[] = "Your ACT Math score is out of the valid range.") : ('');
((($input['act_read'] > 36) || ($input['act_read'] < 1)) && ($input['act_read'] != "")) ? ($errors[] = "Your ACT Reading score is out of the valid range.") : ('');
((($input['act_sci'] > 36) || ($input['act_sci'] < 1)) && ($input['act_sci'] != "")) ? ($errors[] = "Your ACT Science score is out of the valid range.") : ('');
((($input['sat_math'] > 800) || ($input['sat_math'] < 200)) && ($input['sat_math'] != "")) ? ($errors[] = "Your SAT math score is out of the valid range.") : ('');
((($input['sat_verb'] > 800) || ($input['sat_verb'] < 200)) && ($input['sat_verb'] != "")) ? ($errors[] = "Your SAT verbal score is out of the valid range.") : ('');
((($input['sat_writ'] > 800) || ($input['sat_writ'] < 200)) && ($input['sat_writ'] != "")) ? ($errors[] = "Your SAT writing score is out of the valid range.") : ('');
((($input['psat'] > 240) || ($input['psat'] < 60)) && ($input['psat'] != "")) ? ($errors[] = "Your PSAT is out of the valid range.") : ('');
(!array_key_exists($input['nat_merit'], $nationalMeritArray)) ? ($errors[] = "Please indicate whether or not you were awarded National Merit or National Achievement awards.") : ('');
(!array_key_exists($input['ap'], $apCountArray)) ? ($errors[] = "Please estimate how many APs your school offers.") : ('');
(!array_key_exists($input['hs_type'], $hs_type_array)) ? ($errors[] = "Please indicate what type of high school you attend (public, private, magnet, etc.).") : ('');
(!array_key_exists($input['hs_state'], $state_array)) ? ($errors[] = "Please indicate the state that your high school is in.") : ('');
($input['hs_city'] == "") ? ($errors[] = "Please indicate the city that your high school is in.") : ('');
(array_search($input['decile'], $decile_array) === false) ? ($errors[] = "Please indicate your class rank.") : ('');
((!is_numeric($input['class_size']) || $input['class_size'] < 1 || $input['class_size'] > 10000) && $input['class_size'] != "") ? ($errors[] = "If you indicate your class size, it must be numeric (without words, periods, or commas).") : ('');
Use PSR-1 and PSR-2 or steal the standard your favorite open source project follows.
Google was not tested in a day.
Nothing kills a Friday afternoon like slow tests
If you find yourself saying
"Oh I remember fixing this issue last year.."
You should be using regression testing.
Major.Minor.Patch
Packagist keeps track of your git tags, use them to denote new versions
$ git commit -m "Release version 1.0.0"
$ git tag 1.0.0
$ git push
<?php
function foo() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle();
} else if ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
} else if ($c == $d) {
while ($c == $d) {
fiddle();
}
} else if ($e == $f) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
case 1:
fiddle();
break;
case 2:
fiddle();
break;
case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
<?php
function foo() {
if ($a == $b) {
do_a();
} else if ($c == $d) {
handle_b();
} else if ($e == $f) {
handle_c();
} else {
handle_d();
}
}
<?php
/**
* Prepend a string with "Foo: "
*
* ```
* $result = foo("bar");
* echo $result; // "Foo: bar"
* ```
*
* @param string $string
* @return string The prepended string
*/
function foo($string) {
return "Foo: {$string}";
}
Nothing beats natural language explanation.