diff --git a/scripts/Phalcon/Devtools/Version.php b/scripts/Phalcon/Devtools/Version.php index ee6d32536..9b6d2ad75 100644 --- a/scripts/Phalcon/Devtools/Version.php +++ b/scripts/Phalcon/Devtools/Version.php @@ -39,6 +39,6 @@ class Version extends PhVersion */ protected static function _getVersion() { - return [3, 4, 6, 0, 0]; + return [3, 4, 7, 0, 0]; } } diff --git a/scripts/Phalcon/Web/Tools/Controllers/ScaffoldController.php b/scripts/Phalcon/Web/Tools/Controllers/ScaffoldController.php index d74d7e898..c35c48432 100644 --- a/scripts/Phalcon/Web/Tools/Controllers/ScaffoldController.php +++ b/scripts/Phalcon/Web/Tools/Controllers/ScaffoldController.php @@ -21,6 +21,7 @@ namespace WebTools\Controllers; +use PDOException; use Phalcon\Text; use Phalcon\Builder\Scaffold; use Phalcon\Mvc\Controller\Base; @@ -107,10 +108,17 @@ public function generateAction() $this->tag->setDefault('templatesPath', $templatesPath); $this->tag->setDefault('schema', $this->dbUtils->resolveDbSchema()); + try { + $tables = $this->dbUtils->listTables(); + } catch (PDOException $PDOException) { + $tables = []; + $this->flash->error($PDOException->getMessage()); + } + $this->view->setVars( [ 'page_subtitle' => 'Generate code from template', - 'tables' => $this->dbUtils->listTables(), + 'tables' => $tables, 'template_path' => $templatesPath, 'templateEngines' => [ 'volt' => 'Volt', diff --git a/scripts/Phalcon/Web/Tools/Views/controllers/edit.volt b/scripts/Phalcon/Web/Tools/Views/controllers/edit.volt index a50d76a44..49781a44f 100644 --- a/scripts/Phalcon/Web/Tools/Views/controllers/edit.volt +++ b/scripts/Phalcon/Web/Tools/Views/controllers/edit.volt @@ -3,7 +3,7 @@ {{ content() }} {{ flashSession.output() }}
-
+

{{ controller_name }} - [{{ controller_path }}]

{{ submit_button("Save", "class": "btn btn-success pull-right") }} diff --git a/scripts/Phalcon/Web/Tools/Views/controllers/generate.volt b/scripts/Phalcon/Web/Tools/Views/controllers/generate.volt index 34cc644d4..3571012df 100644 --- a/scripts/Phalcon/Web/Tools/Views/controllers/generate.volt +++ b/scripts/Phalcon/Web/Tools/Views/controllers/generate.volt @@ -6,7 +6,7 @@ {{ flashSession.output() }}
- +

{{ controller_name }} - [{{ controller_path }}]

{{ submit_button("Generate", "class": "btn btn-success pull-right") }} diff --git a/scripts/Phalcon/Web/Tools/Views/controllers/index.volt b/scripts/Phalcon/Web/Tools/Views/controllers/index.volt index 06258ba9c..708762461 100644 --- a/scripts/Phalcon/Web/Tools/Views/controllers/index.volt +++ b/scripts/Phalcon/Web/Tools/Views/controllers/index.volt @@ -5,7 +5,7 @@

Controllers List

- {{ link_to("/webtools.php?_url=/controllers/generate", "Generate", 'class': 'btn btn-primary pull-right') }} + {{ link_to(webtools_uri ~ "?_url=/controllers/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
@@ -41,7 +41,7 @@ diff --git a/scripts/Phalcon/Web/Tools/Views/migrations/generate.volt b/scripts/Phalcon/Web/Tools/Views/migrations/generate.volt index 88f178378..54ea439f0 100644 --- a/scripts/Phalcon/Web/Tools/Views/migrations/generate.volt +++ b/scripts/Phalcon/Web/Tools/Views/migrations/generate.volt @@ -6,7 +6,7 @@ {{ flashSession.output() }}
- +

New model will be placed at: [{{ migration_path }}]

{{ submit_button("Generate", "class": "btn btn-success pull-right") }} diff --git a/scripts/Phalcon/Web/Tools/Views/migrations/index.volt b/scripts/Phalcon/Web/Tools/Views/migrations/index.volt index 5b30aafe8..7b11970a3 100644 --- a/scripts/Phalcon/Web/Tools/Views/migrations/index.volt +++ b/scripts/Phalcon/Web/Tools/Views/migrations/index.volt @@ -5,7 +5,7 @@

Migrations List

- {{ link_to("/webtools.php?_url=/migrations/generate", "Generate", 'class': 'btn btn-primary pull-right') }} + {{ link_to(webtools_uri ~ "?_url=/migrations/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
{{ controller.owner }} {{ controller.modified_time }} - {{ link_to("/webtools.php?_url=/controllers/edit/" ~ rawurlencode(controller.filename), + {{ link_to(webtools_uri ~ "?_url=/controllers/edit/" ~ rawurlencode(controller.filename), '', 'class': 'btn btn-default btn-xs') }}
diff --git a/scripts/Phalcon/Web/Tools/Views/migrations/run.volt b/scripts/Phalcon/Web/Tools/Views/migrations/run.volt index 76d71c932..21e831167 100644 --- a/scripts/Phalcon/Web/Tools/Views/migrations/run.volt +++ b/scripts/Phalcon/Web/Tools/Views/migrations/run.volt @@ -6,7 +6,7 @@ {{ flashSession.output() }}
- +

Migrations from: [{{ migration_path }}]

{{ submit_button("Run", "class": "btn btn-success pull-right") }} diff --git a/scripts/Phalcon/Web/Tools/Views/models/edit.volt b/scripts/Phalcon/Web/Tools/Views/models/edit.volt index d09f74dcc..33f8f6ddf 100644 --- a/scripts/Phalcon/Web/Tools/Views/models/edit.volt +++ b/scripts/Phalcon/Web/Tools/Views/models/edit.volt @@ -3,7 +3,7 @@ {{ content() }} {{ flashSession.output() }}
- +

{{ model_name }} - [{{ model_path }}]

{{ submit_button("Save", "class": "btn btn-success pull-right") }} diff --git a/scripts/Phalcon/Web/Tools/Views/models/generate.volt b/scripts/Phalcon/Web/Tools/Views/models/generate.volt index fd4504093..b3bd1a446 100644 --- a/scripts/Phalcon/Web/Tools/Views/models/generate.volt +++ b/scripts/Phalcon/Web/Tools/Views/models/generate.volt @@ -6,7 +6,7 @@ {{ flashSession.output() }}
- +

New model will be placed at: [{{ model_path }}]

{{ submit_button("Generate", "class": "btn btn-success pull-right") }} diff --git a/scripts/Phalcon/Web/Tools/Views/models/index.volt b/scripts/Phalcon/Web/Tools/Views/models/index.volt index 4a93fb62d..b43151469 100644 --- a/scripts/Phalcon/Web/Tools/Views/models/index.volt +++ b/scripts/Phalcon/Web/Tools/Views/models/index.volt @@ -5,7 +5,7 @@

Models List

- {{ link_to("/webtools.php?_url=/models/generate", "Generate", 'class': 'btn btn-primary pull-right') }} + {{ link_to(webtools_uri ~ "?_url=/models/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
@@ -41,7 +41,7 @@ diff --git a/scripts/Phalcon/Web/Tools/Views/scaffold/generate.volt b/scripts/Phalcon/Web/Tools/Views/scaffold/generate.volt index a5580a283..2f74d2df4 100644 --- a/scripts/Phalcon/Web/Tools/Views/scaffold/generate.volt +++ b/scripts/Phalcon/Web/Tools/Views/scaffold/generate.volt @@ -6,7 +6,7 @@ {{ flashSession.output() }}
- +

We will use templates from: [{{ template_path }}]

{{ submit_button("Generate", "class": "btn btn-success pull-right") }} diff --git a/templates/project/micro/config.ini b/templates/project/micro/config.ini index d894fa538..05111479d 100644 --- a/templates/project/micro/config.ini +++ b/templates/project/micro/config.ini @@ -9,4 +9,4 @@ dbname = test modelsDir = ../app/models/ migrationsDir = ../app/migrations/ viewsDir = ../app/views/ -baseUri = /@@name@@/ +baseUri = / diff --git a/templates/project/micro/config.php b/templates/project/micro/config.php index 23d2b8dc7..7b45c0edd 100644 --- a/templates/project/micro/config.php +++ b/templates/project/micro/config.php @@ -20,6 +20,6 @@ 'modelsDir' => APP_PATH . '/models/', 'migrationsDir' => APP_PATH . '/migrations/', 'viewsDir' => APP_PATH . '/views/', - 'baseUri' => '/@@name@@/', + 'baseUri' => '/', ] ]); diff --git a/templates/project/micro/services.php b/templates/project/micro/services.php index cc3669288..74758142e 100644 --- a/templates/project/micro/services.php +++ b/templates/project/micro/services.php @@ -56,3 +56,14 @@ return $connection; }); +/** + * Register router + */ +$di->setShared('router', function () { + $router = new \Phalcon\Mvc\Router(); + $router->setUriSource( + \Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI + ); + + return $router; +}); diff --git a/templates/project/modules/config.ini b/templates/project/modules/config.ini index 81062cf0b..0b1ee4793 100644 --- a/templates/project/modules/config.ini +++ b/templates/project/modules/config.ini @@ -12,4 +12,4 @@ modelsDir = ../apps/frontend/models/ migrationsDir = ../apps/migrations/ cacheDir = ../../cache/ viewsDir = ../apps/frontend/views/ -baseUri = /@@name@@/ +baseUri = / diff --git a/templates/project/modules/config.php b/templates/project/modules/config.php index 92cdc6b16..8c816402b 100644 --- a/templates/project/modules/config.php +++ b/templates/project/modules/config.php @@ -23,11 +23,7 @@ 'modelsDir' => APP_PATH . '/common/models/', 'migrationsDir' => APP_PATH . '/migrations/', 'cacheDir' => BASE_PATH . '/cache/', - - // This allows the baseUri to be understand project paths that are not in the root directory - // of the webpspace. This will break if the public/index.php entry point is moved or - // possibly if the web server rewrite rules are changed. This can also be set to a static path. - 'baseUri' => preg_replace('/public([\/\\\\])index.php$/', '', $_SERVER["PHP_SELF"]), + 'baseUri' => '/', ], /** diff --git a/templates/project/modules/services_web.php b/templates/project/modules/services_web.php index a2a0d0576..a026bd095 100644 --- a/templates/project/modules/services_web.php +++ b/templates/project/modules/services_web.php @@ -15,6 +15,9 @@ $router = new Router(); $router->setDefaultModule('frontend'); + $router->setUriSource( + Router::URI_SOURCE_SERVER_REQUEST_URI + ); return $router; }); diff --git a/templates/project/simple/config.ini b/templates/project/simple/config.ini index e59b37e50..075b97e06 100644 --- a/templates/project/simple/config.ini +++ b/templates/project/simple/config.ini @@ -14,7 +14,7 @@ viewsDir = ../app/views/ pluginsDir = ../app/plugins/ libraryDir = ../app/library/ cacheDir = ../cache/ -baseUri = /@@name@@/ +baseUri = / [models] metadata.adapter = "Memory" diff --git a/templates/project/simple/config.php b/templates/project/simple/config.php index 0dc396963..0dba3b65f 100644 --- a/templates/project/simple/config.php +++ b/templates/project/simple/config.php @@ -24,10 +24,6 @@ 'pluginsDir' => APP_PATH . '/plugins/', 'libraryDir' => APP_PATH . '/library/', 'cacheDir' => BASE_PATH . '/cache/', - - // This allows the baseUri to be understand project paths that are not in the root directory - // of the webpspace. This will break if the public/index.php entry point is moved or - // possibly if the web server rewrite rules are changed. This can also be set to a static path. - 'baseUri' => preg_replace('/public([\/\\\\])index.php$/', '', $_SERVER["PHP_SELF"]), + 'baseUri' => '/', ] ]); diff --git a/templates/project/simple/services.php b/templates/project/simple/services.php index c7edc67ff..e369ccfe8 100644 --- a/templates/project/simple/services.php +++ b/templates/project/simple/services.php @@ -1,5 +1,6 @@ setShared('router', function () { + $router = new Router(); + $router->setUriSource( + Router::URI_SOURCE_SERVER_REQUEST_URI + ); + + return $router; +});
{{ model.owner }} {{ model.modified_time }} - {{ link_to("/webtools.php?_url=/models/edit/" ~ rawurlencode(model.filename), + {{ link_to(webtools_uri ~ "?_url=/models/edit/" ~ rawurlencode(model.filename), '', 'class': 'btn btn-default btn-xs') }}