I am wondering if it is possible to choose environment when generating urls with the symfony routing component.
In a controller
$this->generateUrl($route, $params);
generates / in prod envrionment and /app_dev.php in dev.
There doesn't seem to be a parameter for the environment so that you could generate productive urls in dev environment. I just don't want to use something like str_replace all the time.
This would be great:
$this->generateUrl($route, $params, 'prod');
For your understanding, I am working on a cms project where I have to match uris against the database where they are stored without app_dev.php.
Any ideas?
More of a hack than a proper solution, you can set the Context's $baseUrl to be '' (as it would in production environment) before calling the generateUrl and reset-ting it back after the call. The RequestContext->getBaseUrl is consulted each time the complete Url is built.
In our case, we had to build Urls without the app_dev or app.php because our frontend was an AngularJS based application matching the URLs. In this case, since we dint want the app_dev or app.php at all, we created an EventListener that does a
$this->router->getContext()->setBaseUrl('');
Router component workflow doesn't include any of app.php or app_dev.php files. It only works with the pattern which comes after php file in the query string, whatever that file is.
So you're not able to do that. You only can use .htaccess file config to manage what file will be used as a default one, no more.
Related
I deployed my app in example.com/app but all my routes are broken.
Oops, looks like there's no route on the client or the server for url: "http://example.com/app/."
I can try to manually prepend to all routes /app/ subfolder but it doens't seem the right approach, especially since i use a cms package (orionjs) to generate the /admin interface, which doesn't have support to change the admin path.
Is there any way to prepend the /app folder to all routes by default?
What i find strange is that i defined ROOT_URL to http://example.com/app/ but iron router seems to ignore it. Did i skip a step ?
Unlike many web platforms (ex: php), the folder structure under your app does not map automatically to routes. If you're using iron-router you basically define what layout maps to what route. The layout can be defined in an HTML file in any folder (except under /server or /public) at any depth. You can also add any extra depth you want to any route in iron-router by prepending app/ or whatever you want to your route definitions. Your ROOT_URL should remain http://example.com/
I have an instance of Silverstripe that we have copied off a webserver that we host. We are trying to get it running locally so we can modify it but when I run it locally all assets point to the live site. Also I cannot access the login, or Admin pages of the CMS.
When I try access any local pages it states "Server Error" in the page content
Is there a place in the code where I can change the paths to assets to local, and also access the Admin area?
Assuming you're running a local copy of the database, and don't have any exotic changes to the way File is handled SilverStripe should be resolving file paths using the BASE_PATH and BASE_URL constants.
For logging in you'll want to add to the bottom of mysite/_config.php locally something like:
define('SS_ENVIRONMENT_TYPE', 'dev');
SSViewer::set_source_file_comments(true);
ini_set('display_errors', 0);
error_reporting(E_ALL);
Security::setDefaultAdmin('admin', 'admin');
// Email::setAdminEmail('admin#example.org');
define('SS_LOG_FILE',dirname(__FILE__).'/'.basename(dirname(dirname(__FILE__))).'.log');
ini_set('error_log', SS_LOG_FILE);
Director::set_environment_type('dev');
This should give you enough debug information to solve most issues.
I would use something like https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ (which also works for Silverstripe), to do a search and replace for all occurences of the old domain.
This would mainly work for images paths that are inside of content fields of course. Otherwise, SS should automatically convert the paths, as the accepted answer suggests.
I am trying to get my app to run behind an NGINX reverse proxy and had some minor success.
the path is http://dev.sertal.ch/myApp and the application is accessible.
The issue I am still facing is that the images in the public folder are not accessible without hard coding myApp at the start of the URL. This is especially an issue for URLs inside the CSS.
You would want to set the ROOT_URL environment variable when you start your meteor app. If you are using meteor to start from the command line in your app's directory it would be like this:
ROOT_URL=http://dev.sertal.ch/myApp meteor
Meteor has a ROOT_URL property which you must explicitly set for your bundled applications.
It is in the form of Meteor.absoluteUrl([path], [options]) and the path argument is exactly what you're looking for, excerpt from the docs:
A path to append to the root URL. Do not include a leading "/".
Check here for details on options http://docs.meteor.com/#/full/meteor_absoluteurl
I'm looking for a way to expose my test environment via a subdomain. Basically, I want to do the equivalent of the console --env "test" via URL. So someone accessing http://example.com will get the production site, but the external testers can go to http://test.example.com and will get the test environment, with test database and everything.
I thought just using SetEnv ENV "test" in my apache config would do the trick, but apparently it doesn't.
I'm fairly sure this is a pretty common thing, so can someone guide me to the solution?
It's really weird that you're trying to access test environment through url, but I'll guess you need some special configuration for WebTestCases.
You need to create app_test.php file in web directory, and boot kernel with 'test' environment parameter. To see how to do it, check out already available app.php and app_dev.php files.
After that, setup your apache to aim for app_test.php when you hit your url. Also have in mind that you will probably have to make apache ignore .htaccess because it will point it to app.php. You can do it using AllowOverride None.
I have an application in Symfony 2. It is deployed on IIS server.
The problem is, I need to get it work on multiple URLs:
www.somedomain.com/myapp/app.php - for production
www.somedomain.com/myappdev/app.php - for testing
myapp.localhost/app.php - for development
How can I do that? I need to correctly generate URL for resources(js, css files). Also after deployment, generated URL are missing the /myapp/ (/myappdev/) segment.
You can prefix your routes with /myappdev by adding it to your app/config/routing.yml file under the prefix key.
If you use relative URLs for the resources then you won't have a problem with the domain it's on and it will work anywhere you put it.