Symfony - Can not redirect requests to index.php
netpyceb
HOBBYOP

a year ago

Hello people

I am tryuing to deploy a Symfony app. All cool, it is deployed, byt works only with main index.php in the /public/ folder.

As soon as I go to e.g. domain.com/health-check - it actually loads gile index.php from the folder /public/health-check/index.php, and not frmo the main public/index.php

I tried to use .htaccess file, I tried to create multiple nginx.conf and nginx.template.conf, and I tried using Caddyfile...

I put them in different folders...

I write any grbage in them, correct or not....

They are NOT picked up. No changes at all, no good, no bad. Many random folders tried. Nothing.

How do I point it in tha Railway UI? Where should it be in the code? How do I know that that file even found or exists in the service container?

Solved

7 Replies

netpyceb
HOBBYOP

a year ago

I have a hundred of repos to migrate to the cloud, I have 20 years of dev experience, and I can not solve this "not working on Railway" ticket for like 3 days already, I simply do not see any direct manuals or logs or UI fields to use.

Please help.


netpyceb
HOBBYOP

a year ago

I posted the same publicly. Sorry, again the same issue with UI even in help section - I do not see any button to "make it public" or even delete/close the ticket.


unicodeveloper
PRO

a year ago

Hi, I just accessed your service and it works fine. The routes also work fine.

What exactly is the challenge here as it is difficult to know from your multiple posts?


Status changed to Awaiting User Response Railway about 1 year ago


netpyceb
HOBBYOP

a year ago

The issue is, when I go to index page https://tarrot-api-production.up.railway.app/ it shows me the output from the /public/index.php - this is ok

When I go to https://tarrot-api-production.up.railway.app/health-check/ - it shows me the output of basically the code in /health-check/ folder, which is not fine. I even removed it to see 404 now anyway.

All request must go to general main index.php, so when I go to https://tarrot-api-production.up.railway.app/health-check/ - it should go to public/index.php and the code resolved wich Controller and output to show.

I could not find a way to properly forward all borser requests to that one path public/index.php disregarding the url

Please help to understand where to put (how?) a ocnfig file, with example please, to route all requests to main index.php file.

I am using Symfony 7, and perhaps you can see the code in the container, or I can give you any content you need for investigation pray emojipleading_face emoji

I have the code like that, if it matters:


#[Route('')]
class IndexController extends AbstractController
{
    #[Route('', name: 'app_index', methods: ['GET'])]
    public function index(Request $request): JsonResponse
    {
        return new JsonResponse(['Nothing' => 'here']);
    }

    #[Route('/health-check', name: 'app_health_check', methods: ['GET'])]
    public function healthCheck(Request $request): JsonResponse
    {
        return new JsonResponse(['status' => 'ok']);
    }
}

so when the browser hits /health-check - it should go to main public/index.php and jsut resolve the path to the method ()


Status changed to Awaiting Railway Response Railway about 1 year ago


a year ago

Hello,

I think you'd want to set the NIXPACKS_PHP_FALLBACK_PATH variable -

https://nixpacks.com/docs/providers/php


Status changed to Awaiting User Response Railway about 1 year ago


netpyceb
HOBBYOP

a year ago

You are my hero superhero emoji

It worked out. Thanks.

I will post any other update if I find issues, but for now - this is resolved.

Also, I will update another (public) thread with the solution for whoever will find it later.


Status changed to Awaiting Railway Response Railway about 1 year ago


a year ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody about 1 year ago


a year ago

Happy I could help, in the future please do not open duplicate threads, and only open private threads for billing related questions.


Status changed to Solved brody about 1 year ago


Loading...