From a61e5dcfd70da73094502c9286d12fa52f0601e5 Mon Sep 17 00:00:00 2001 From: Kris Jordan Date: Sun, 15 Mar 2009 23:17:52 +0800 Subject: [PATCH 1/3] Friendlier fail messages for missing PDO/PDO drivers. Stopgap for a true install experience. Signed-off-by: Recess PHP Framework --- bootstrap.php | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 22d29c5..1061361 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -100,10 +100,45 @@ static function init() { Library::import('recess.database.orm.ModelDataSource'); if(empty(RecessConf::$defaultDatabase)) { - die('Congratulations, Recess is almost setup!
Next step: Setup recess-conf.php to point to your database. Checkout the README.textile file for detailed instructions.'); + $message = 'Congratulations, Recess is almost setup!
'; + $message .= 'Next Step(s):'; + $message .= ''; + die($message); } - Databases::setDefaultSource(new ModelDataSource(RecessConf::$defaultDatabase));//,RecessConf::$defaultDatabase[1],RecessConf::$defaultDatabase[2])); + try { + Databases::setDefaultSource(new ModelDataSource(RecessConf::$defaultDatabase)); + } catch(DataSourceCouldNotConnectException $e) { + $databaseType = parse_url(RecessConf::$defaultDatabase[0], PHP_URL_SCHEME); + if(!in_array($databaseType, pdo_drivers())) { + $message = 'It looks like PHP could not load the driver needed to connect to ' . RecessConf::$defaultDatabase[0] . '
'; + $message .= 'Please install the ' . ucfirst($databaseType) . ' PDO driver and enable it in php.ini'; + } else { + $message = 'Error connecting to data source: ' . $e->getMessage(); + } + die($message); + } if(!empty(RecessConf::$namedDatabases)) { foreach(RecessConf::$namedDatabases as $name => $sourceInfo) { Databases::addSource($name, new ModelDataSource($sourceInfo)); From 0fdaa0fc3f9080bfc129cfde76a43ade897e7895 Mon Sep 17 00:00:00 2001 From: KrisJordan Date: Fri, 13 Mar 2009 07:56:16 +0800 Subject: [PATCH 2/3] Major rewrite of low-level components in recess.lang to standardize the expansion of annotations and introduce Wrappable methods for simple extensibility. Sub-history of commits: Wrapping of methods created on FrameworkObject, RecessObject renamed Object. Model still broken, it is up next. Getting closer with models running on FrameworkObject base. Still failing on multiple unit tests. FrameworkObject integrated into main stack. All tests passing. Documentation for FrameworkObject and some restructuring. Made model::save, controller::serve wrappable. Fleshing out of FrameworkAnnotation Refactoring FrameworkObject merged into Object, all Recess annotations rewritten to use the new model. Tweaks in wrappingTests app, not to be merged into official tree. Made RoutesPrefix Annotation conform to new standard. Adding comments to new recess.lang features Signed-off-by: Recess PHP Framework --- .../WelcomeHomeController.class.php | 3 +- bootstrap.php | 4 +- recess-conf.php | 6 +- recess/lib/recess/Recess.class.php | 4 +- .../RecessToolsAppsController.class.php | 2 +- .../apps/tools/templates/header.template.php | 2 +- .../apps/tools/views/apps/createModel.php | 2 +- .../tools/views/apps/newAppWizardComplete.php | 2 +- .../recess/apps/tools/views/common/footer.php | 8 +- .../recess/apps/tools/views/common/header.php | 4 +- .../apps/tools/views/database/newSource.php | 2 +- .../lib/recess/apps/tools/views/home/home.php | 4 +- recess/lib/recess/cache/Cache.class.php | 2 +- .../lib/recess/database/Databases.class.php | 4 +- .../lib/recess/database/orm/Model.class.php | 101 +++---- .../AbstractRelationshipAnnotation.class.php | 51 ++++ .../annotations/BelongsToAnnotation.class.php | 36 ++- .../annotations/ColumnAnnotation.class.php | 54 ++-- .../annotations/DatabaseAnnotation.class.php | 30 +- .../annotations/HasManyAnnotation.class.php | 35 ++- .../orm/annotations/ModelAnnotation.class.php | 50 ---- .../ModelPropertyAnnotation.class.php | 19 -- .../orm/annotations/TableAnnotation.class.php | 32 ++- .../BelongsToRelationship.class.php | 10 +- .../HasManyRelationship.class.php | 10 +- .../orm/relationships/Relationship.class.php | 4 +- .../pdo/IPdoDataSourceProvider.class.php | 4 +- .../pdo/MysqlDataSourceProvider.class.php | 4 +- .../recess/database/pdo/PdoDataSet.class.php | 4 +- .../database/pdo/PdoDataSource.class.php | 8 +- .../pdo/RecessColumnDescriptor.class.php | 4 +- .../pdo/RecessTableDescriptor.class.php | 4 +- .../recess/database/pdo/RecessType.class.php | 4 +- ...taSourceCouldNotConnectException.class.php | 4 +- .../ProviderDoesNotExistException.class.php | 6 +- .../database/sql/ISqlConditions.class.php | 4 +- .../database/sql/ISqlSelectOptions.class.php | 4 +- .../recess/database/sql/SqlBuilder.class.php | 10 +- .../recess/diagnostics/Diagnostics.class.php | 9 +- .../diagnostics/output/exception_report.php | 7 +- .../recess/framework/Application.class.php | 4 +- .../recess/framework/DefaultPolicy.class.php | 1 + .../controllers/AbstractController.class.php | 14 +- .../controllers/Controller.class.php | 67 ++--- .../ControllerAnnotation.class.php | 9 - .../annotations/RouteAnnotation.class.php | 87 +++--- .../RoutesPrefixAnnotation.class.php | 31 ++- .../annotations/ViewAnnotation.class.php | 36 +-- .../interfaces/IController.class.php | 2 +- .../framework/views/AbstractView.class.php | 4 +- recess/lib/recess/http/Cookie.class.php | 4 +- recess/lib/recess/http/Environment.class.php | 2 +- recess/lib/recess/http/Formats.class.php | 4 +- .../recess/http/ForwardingResponse.class.php | 4 +- recess/lib/recess/http/Methods.class.php | 4 +- recess/lib/recess/http/Request.class.php | 6 +- recess/lib/recess/http/Response.class.php | 4 +- .../lib/recess/http/ResponseCodes.class.php | 6 +- recess/lib/recess/lang/Annotation.class.php | 248 ++++++++++++++++- .../lib/recess/lang/AttachedMethod.class.php | 48 ++++ .../lib/recess/lang/ClassDescriptor.class.php | 90 ++++++ recess/lib/recess/lang/IWrapper.class.php | 46 ++++ recess/lib/recess/lang/Inflector.class.php | 4 +- recess/lib/recess/lang/Library.class.php | 6 +- recess/lib/recess/lang/Object.class.php | 257 ++++++++++++++++++ recess/lib/recess/lang/RecessObject.class.php | 218 --------------- .../recess/lang/WrappableAnnotation.class.php | 63 +++++ .../lib/recess/lang/WrappedMethod.class.php | 119 ++++++++ .../lib/recess/lang/codegen/CodeGen.class.php | 4 +- .../lang/codegen/CodeGenClass.class.php | 4 +- .../lang/codegen/CodeGenClassFile.class.php | 4 +- .../lang/codegen/CodeGenClassMember.class.php | 4 +- .../lang/codegen/CodeGenDocComment.class.php | 4 +- .../lang/codegen/CodeGenImport.class.php | 4 +- .../lang/codegen/CodeGenMethod.class.php | 4 +- .../lang/codegen/CodeGenProperty.class.php | 4 +- .../InvalidAnnotationValueException.class.php | 4 +- .../UnknownAnnotationException.class.php | 4 +- .../RecessReflectionClass.class.php | 16 +- .../RecessReflectionMethod.class.php | 4 +- .../RecessReflectionProperty.class.php | 5 +- recess/test/recess/database/orm/ModelTest.php | 84 +----- .../test/recess/lang/FrameworkObjectTest.php | 141 ++++++++++ recess/test/recess/lang/ObjectTest.php | 63 +++++ .../test/recess/lang/RecessLangAllTests.php | 8 +- recess/test/recess/lang/RecessObjectTest.php | 63 ----- .../RecessReflectionClassTest.php | 2 +- 87 files changed, 1529 insertions(+), 842 deletions(-) create mode 100644 recess/lib/recess/database/orm/annotations/AbstractRelationshipAnnotation.class.php delete mode 100644 recess/lib/recess/database/orm/annotations/ModelAnnotation.class.php delete mode 100644 recess/lib/recess/database/orm/annotations/ModelPropertyAnnotation.class.php delete mode 100644 recess/lib/recess/framework/controllers/annotations/ControllerAnnotation.class.php create mode 100644 recess/lib/recess/lang/AttachedMethod.class.php create mode 100644 recess/lib/recess/lang/ClassDescriptor.class.php create mode 100644 recess/lib/recess/lang/IWrapper.class.php create mode 100644 recess/lib/recess/lang/Object.class.php delete mode 100644 recess/lib/recess/lang/RecessObject.class.php create mode 100644 recess/lib/recess/lang/WrappableAnnotation.class.php create mode 100644 recess/lib/recess/lang/WrappedMethod.class.php rename recess/lib/recess/lang/{ => reflection}/RecessReflectionClass.class.php (80%) rename recess/lib/recess/lang/{ => reflection}/RecessReflectionMethod.class.php (93%) rename recess/lib/recess/lang/{ => reflection}/RecessReflectionProperty.class.php (88%) create mode 100644 recess/test/recess/lang/FrameworkObjectTest.php create mode 100644 recess/test/recess/lang/ObjectTest.php delete mode 100644 recess/test/recess/lang/RecessObjectTest.php rename recess/test/recess/lang/{ => reflection}/RecessReflectionClassTest.php (97%) diff --git a/apps/welcome/controllers/WelcomeHomeController.class.php b/apps/welcome/controllers/WelcomeHomeController.class.php index 953dc44..b97d535 100644 --- a/apps/welcome/controllers/WelcomeHomeController.class.php +++ b/apps/welcome/controllers/WelcomeHomeController.class.php @@ -13,5 +13,6 @@ function index() { } + } -?> \ No newline at end of file +?> diff --git a/bootstrap.php b/bootstrap.php index 1061361..496c87d 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,6 +1,6 @@ */ @@ -19,7 +19,7 @@ Library::import('recess.http.Environment'); Library::import('recess.Recess'); -// Entry point to Recess! +// Entry point to Recess Recess::main(Environment::getRawRequest(), RecessConf::$policy, RecessConf::$applications, RecessConf::getRoutes(), RecessConf::$plugins); // RecessConf follows... diff --git a/recess-conf.php b/recess-conf.php index d6353d3..f8a029f 100644 --- a/recess-conf.php +++ b/recess-conf.php @@ -1,8 +1,8 @@ \ No newline at end of file +?> diff --git a/recess/lib/recess/Recess.class.php b/recess/lib/recess/Recess.class.php index 55af586..63eef9b 100644 --- a/recess/lib/recess/Recess.class.php +++ b/recess/lib/recess/Recess.class.php @@ -1,7 +1,7 @@ request->post; $modelName = $values['modelName']; diff --git a/recess/lib/recess/apps/tools/templates/header.template.php b/recess/lib/recess/apps/tools/templates/header.template.php index 2f46fba..3b75190 100644 --- a/recess/lib/recess/apps/tools/templates/header.template.php +++ b/recess/lib/recess/apps/tools/templates/header.template.php @@ -8,7 +8,7 @@ - <?php if(isset($title)) echo $title; else echo 'Recess!'; ?> + <?php if(isset($title)) echo $title; else echo 'Recess'; ?>