URLs with domain name in symfony - php

I'm pretty new to working with Symfony and I cannot find a way around my problem:
I have a domain, say testing.domain.tld where I deploy my app for testing purposes. Routing works as expected for all my self written controllers, but when i send an email or in easyadmin, the generated URL is something like 127.0.0.1:8080/route instead of testing.domain.tld/route.
This can probably be done in config, but I do not see where/how...
I would be very thankful for any hints!

You have to configure the router request context base url. If you are using at least Symfony 5.1 you can configure it via the framework.router.default_uri configuration key, otherwise you have to specify the host, scheme and base path of your application.
Read more about this feature in this post from symfony blog

Related

How to change wordpress links on app engine?

I have 2 app engine services named default and WordPress and I dispatched routes. When I go to appspot.com/wordpress it is working but in the other links like appspot.com/category instead of appspot.com/wordpress/category
How can I configure WordPress source files or files of WordPress to solve my problem?
You should be able to achieve this by configuring your dispatch.yaml file.
As it is stated in the official documentation:
You can use wildcard mappings with services in App Engine by using the dispatch.yaml file to define request routing to specific services.
Here you can find a good example of wildcard usage for achieving your purpose. In case you have difficulties implementing it you can share your dispatch.yaml file and I will check it out.
EDIT:
In case you want to use more than 20 url routing rules there is already a feature request created for this. A way you can manage to do your routing without exceeding the limit, would be creating more backend services, rather than a monolithical application and directly route the requests to them using their full target address through your frontend default service. Spliting the architecture would be a good idea in case you need to "trick" somehow the 20 url quota.

Implementing Multi-tenancy in Laravel

I am using Laravel 5.4 with having Laravel Voyager Installed.
The main requirements of the project are to have the multi-tenant domain based application i.e. app.com and {client}.app.com
I have been trying to load configurations based on a subdomain and will act subdomain as the client code
which worked fine on localhost but while I am pushing changes to live server things are not working
As a beginner in this scope, I am not sure how thing will work on the live environment, in terms of domain redirection and setting up options in middleware, or mainly how wildcard subdomain would work in laravel's subdomain routing
You can use this package: https://github.com/hyn/multi-tenant
I've used this many times and can confirm it works extremely well. As an added bonus, there's a very detailed tutorial you can use to get going here: https://laravel-tenancy.com/docs/hyn/5.x/full-featured-tutorial

Custom Domain mapping in cloud based application

I am creating a cloud based application in laravel/php.
I have a functionality where user can have their website at user.myapp.com and it works (with subdomain and model binding).
I now want to go one step further, and allow users to add their own custom domain names. So their website will be reachable at user-domain.com rather than (or as well as) user.myapp.com.
I want to understand how to do this. I'm using Laravel framework which is based on php and apache.
What kind of server do I need? Can I use shared hosting?
What configs do I need to do in order for this to work?
What DNS record the user must create to put things together?
You can do this with any kind of server. You can make a route that is caught by any domain and in the controller of this route, you can query the database to know what website should be displayed for that domain.
You can get the domain name of the current request using app('request')->root();

Symfony2 ignore certain route

I have the following situation:
I'm running a Symfony 2 project on a server with the route www.homepage.de.
Every request to a random route on www.homepage.de will be routed to my Landing Page.
Now I want to integrate another project, an API build with Slim PHP and Swagger UI, into this Symfony 2 project. I cloned the project into the /web directory of the Symfony2 project to gurantee access to it.
But now every request I want to do to www.homepage.de/api fails because the Symfony 2 project wants to handle the request and can't find the route. Is there a possibility to tell Symfony2 to ignore every request that is send to the www.homepage.de/api route?
First of all don't add anything to web folder of your application. Just create two applications in different folders. If you want the API to be accessible through the same domain but just with /api you cen use either mod_alias or mod_rewrite to achieve this.
In your current solution it is not Symfony that is intercepting your requests. Take a look at your .htaccess. This is where the magic happens. You can always modify rewrite rules to intercept all /api requests and redirect them to your application but I would still suggest to keep those projects apart.

Redirecting to mobile subdomain in a CI application

I have a web app of which I would like to create a mobile version with jQuery Mobile. The existing application is built in CodeIgniter; I'll be using the same controllers, models where I can; (especially models since I'll be needing the same data anyway, might have to write new controllers).
I'm a bit confused as to how to get started. I want to put my mobile version on a subdomain (m.myhost.tld), however.. since my app is at www.myhost.tld and I don't feel like copying it all over to another folder and maintain two, I'm a bit confused.
I know I can use the User Agent library in CodeIgniter to detect mobile browsers and load views accordingly; I just don't know how to get this working with a subdomain. Do I need to customize my app/config/routes.php file here, or can I fix this with some .htaccess magic? I have next to none experience with .htaccess though. The only thing I know is how to remove my index.php from CI apps, and that's a copypasta snippet.
EDIT: I wonder if I can use a tutorial like this one to do what I want to do? It seems to be doing more or less the same thing, just with dynamic usernames instead of a simple 'm.'
EDIT 2: Some more information, I guess.
Say I detect mobile browsers using the User Agent library included with CodeIgniter. I want to direct these browsers to m.myhost.tld. However, the content that I want to display on the mobile website comes from a controller called mobile which I can also access through www.myhost.tld/mobile/; so my question is if there is a way to route a URL like.. for example www.myhost.tld/mobile/about to m.myhost.tld/about. I'm not even sure if this is possible, teehee. Still learning!
I'll be grateful for any advice you can give me. Thanks a lot!
If you want to share the same files in different hosts, you must assign the document root folder of your sites in your web server, this is an explanation for static files, but is the base to you understand.
browser -> host:z.y.xxx[ip.ip.ip.ip] -> web server -> read filesystem : document root + browser request path
so if your document root is:
/hosting/http/z.y.xxx/htdocs
and the request is /path-to-static/index.html the server try to read:
/hosting/http/z.y.xxx/htdocs/path-to-static/index.html
In conclution, you create the new host m.mysite.tld in your web server and you change the document root as the same of the you www.mysite.tld also you could use directives of host alias, like Apache ServerAlias directive. Have lot of documentation to how you could configure a web server.
You could handle the host name in php with $_SERVER['HTTP_HOST'] variable.
If you could specify more, I could help more.
have a nice day

Categories