简体   繁体   中英

Symfony2 project on a distant server problems

I'm now looking about 2 weeks for running a website (very simple, just for testing the first steps like a HelloWorld) on a hosting, but still nothing.

I'm new on symfony and it could be that my error is "normal" but I cannot find my answer on the internet. So my problem is the following:

I developed a website on my PC with symfony2. It has just a little html/css page which I would like to see on the server. Locally, everything works fine: no errors, nothing. When I upload the entire project (after clearing cache) via FTP on the hosting ( http://www.nexlink.ch/ ) I've got the following error:

Oops! An Error Occurred

The server returned a "500 Internal Server Error".

Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

and the logger tells me the following things:

INFO - Matched route "HelloTheWorld" (parameters: "_controller": "fcbgNewsBundle:news:index", "name": "bolet", "_route": "HelloTheWorld")

CRITICAL - Uncaught PHP Exception InvalidArgumentException: "Unable to find controller "fcbgNewsBundle:news" - class "fcbg\newsBundle\Controller\newsController" does not exist." at /mnt/sites/fc-beroche.ch/web/fusio/app/cache/dev/classes.php line 2333 
Context: {"exception":"Object(InvalidArgumentException)"}

What did I do wrong?

Here my controller:

<?php

namespace fcbg\newsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class newsController extends Controller
{
  public function indexAction($name)
  {
    echo $name;
    $page = $this->render(
            'base.html.twig', 
            array(
                'content' => 'fcbgNewsBundle:Default:index.html.twig',
                'titrePage' => $name,
                'navigation' => array(
                    array(
                        'href' => 'http://www.youpi.com', 
                        'titre' => 'menu1'
                    ),
                    array(
                        'href' => 'http://www.youpi.com', 
                        'titre' => 'menu2'
                    ),
                    array(
                        'href' => 'http://www.youpi.com', 
                        'titre' => 'menu3'
                    ),
                ),
                'css' => 'fcbgNewsBundle:Default:basicStyle.css'
            )
    );
    return $page;
  }
}

The problem is probably here:

INFO - Matched route "HelloTheWorld" (parameters: "_controller": "fcbgNewsBundle:news:index", "name": "bolet", "_route": "HelloTheWorld")

As you can see this:

fcbgNewsBundle:news:index

It is expected as

fcbg\NewsBundle\newsController -> indexAction

But you have:

namespace fcbg\newsBundle\Controller;
               ^

n character with lover-case . Use upper-case and you should also use upper-cased characters at the start of your controller names ( NewsController instead of newsController ) to avoid these problems in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM