Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1305 - Fix URL during phalcon serve #1350

Merged
merged 5 commits into from
Nov 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/controllers/edit.volt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ content() }}
{{ flashSession.output() }}
<div class="box box-success">
<form role="form" name="edit-controller" method="post" action="{{ url.get("/webtools.php?_url=/controllers/update") }}">
<form role="form" name="edit-controller" method="post" action="{{ url.get(webtools_uri ~ "?_url=/controllers/update") }}">
<div class="box-header with-border">
<p class="pull-left">{{ controller_name }} - [{{ controller_path }}]</p>
{{ submit_button("Save", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/controllers/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-controller" method="post" action="{{ url.get("/webtools.php?_url=/controllers/generate") }}">
<form role="form" class="form-horizontal" name="generate-controller" method="post" action="{{ url.get(webtools_uri ~ "?_url=/controllers/generate") }}">
<div class="box-header with-border">
<p class="pull-left">{{ controller_name }} - [{{ controller_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Web/Tools/Views/controllers/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="box-header">
<h3 class="box-title">Controllers List</h3>
{{ 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') }}
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
Expand Down Expand Up @@ -41,7 +41,7 @@
<td>{{ controller.owner }}</td>
<td>{{ controller.modified_time }}</td>
<td>
{{ link_to("/webtools.php?_url=/controllers/edit/" ~ rawurlencode(controller.filename),
{{ link_to(webtools_uri ~ "?_url=/controllers/edit/" ~ rawurlencode(controller.filename),
'<i class="fa fa-pencil"></i>', 'class': 'btn btn-default btn-xs') }}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/migrations/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get("/webtools.php?_url=/migrations/generate") }}">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get(webtools_uri ~ "?_url=/migrations/generate") }}">
<div class="box-header with-border">
<p class="pull-left">New model will be placed at: [{{ migration_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/migrations/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="box-header">
<h3 class="box-title">Migrations List</h3>
{{ 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') }}
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover table-bordered">
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/migrations/run.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get("/webtools.php?_url=/migrations/run") }}">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get(webtools_uri ~ "?_url=/migrations/run") }}">
<div class="box-header with-border">
<p class="pull-left">Migrations from: [{{ migration_path }}]</p>
{{ submit_button("Run", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/models/edit.volt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ content() }}
{{ flashSession.output() }}
<div class="box box-success">
<form role="form" name="edit-model" method="post" action="{{ url.get("/webtools.php?_url=/models/update") }}">
<form role="form" name="edit-model" method="post" action="{{ url.get(webtools_uri ~ "?_url=/models/update") }}">
<div class="box-header with-border">
<p class="pull-left">{{ model_name }} - [{{ model_path }}]</p>
{{ submit_button("Save", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/models/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-model" method="post" action="{{ url.get("/webtools.php?_url=/models/generate") }}">
<form role="form" class="form-horizontal" name="generate-model" method="post" action="{{ url.get(webtools_uri ~ "?_url=/models/generate") }}">
<div class="box-header with-border">
<p class="pull-left">New model will be placed at: [{{ model_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Web/Tools/Views/models/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="box-header">
<h3 class="box-title">Models List</h3>
{{ 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') }}
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
Expand Down Expand Up @@ -41,7 +41,7 @@
<td>{{ model.owner }}</td>
<td>{{ model.modified_time }}</td>
<td>
{{ link_to("/webtools.php?_url=/models/edit/" ~ rawurlencode(model.filename),
{{ link_to(webtools_uri ~ "?_url=/models/edit/" ~ rawurlencode(model.filename),
'<i class="fa fa-pencil"></i>', 'class': 'btn btn-default btn-xs') }}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/scaffold/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-scaffold" method="post" action="{{ url.get("/webtools.php?_url=/scaffold/generate") }}">
<form role="form" class="form-horizontal" name="generate-scaffold" method="post" action="{{ url.get(webtools_uri ~ "?_url=/scaffold/generate") }}">
<div class="box-header with-border">
<p class="pull-left">We will use templates from: [{{ template_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion templates/project/micro/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ dbname = test
modelsDir = ../app/models/
migrationsDir = ../app/migrations/
viewsDir = ../app/views/
baseUri = /@@name@@/
baseUri = /
2 changes: 1 addition & 1 deletion templates/project/micro/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
'modelsDir' => APP_PATH . '/models/',
'migrationsDir' => APP_PATH . '/migrations/',
'viewsDir' => APP_PATH . '/views/',
'baseUri' => '/@@name@@/',
'baseUri' => '/',
]
]);
11 changes: 11 additions & 0 deletions templates/project/micro/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
2 changes: 1 addition & 1 deletion templates/project/modules/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ modelsDir = ../apps/frontend/models/
migrationsDir = ../apps/migrations/
cacheDir = ../../cache/
viewsDir = ../apps/frontend/views/
baseUri = /@@name@@/
baseUri = /
6 changes: 1 addition & 5 deletions templates/project/modules/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '/',
],

/**
Expand Down
3 changes: 3 additions & 0 deletions templates/project/modules/services_web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
$router = new Router();

$router->setDefaultModule('frontend');
$router->setUriSource(
Router::URI_SOURCE_SERVER_REQUEST_URI
);

return $router;
});
Expand Down
2 changes: 1 addition & 1 deletion templates/project/simple/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ viewsDir = ../app/views/
pluginsDir = ../app/plugins/
libraryDir = ../app/library/
cacheDir = ../cache/
baseUri = /@@name@@/
baseUri = /

[models]
metadata.adapter = "Memory"
6 changes: 1 addition & 5 deletions templates/project/simple/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '/',
]
]);
13 changes: 13 additions & 0 deletions templates/project/simple/services.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Phalcon\Mvc\Router;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Php as PhpEngine;
use Phalcon\Mvc\Url as UrlResolver;
Expand Down Expand Up @@ -110,3 +111,15 @@

return $session;
});

/**
* Register router
*/
$di->setShared('router', function () {
$router = new Router();
$router->setUriSource(
Router::URI_SOURCE_SERVER_REQUEST_URI
);

return $router;
});