Symfony2: Routing zum StartBundle

Saheeda

Top Contributor
Hallo,

vielleicht kann mir ja hier jemand helfen.

Ich habe mein erstes Symfony2-Projekt erstellt. Von Netbeans wurden dabei auch automatisch einige Demofiles mit erstellt. (src/Acme/DemoBundle). Was ich aber auch trotz googlen noch nicht raus habe ist, wie ich einen eigenen Pfad (z.B. src/MyProject/StartBundle) als Einstiegspunkt definiere bzw. im Browser addressiere.


In einem Tut stand, man solle fürs Ausführen als Startdatei die app_dev.php auswählen, aber dort finde ich auch nirgendwo einen Verweis auf diesen voreingestellten Pfad.


app_dev.php
Code:
<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

AppKernel.php
Code:
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
            new Acme\HelloBundle\AcmeHelloBundle(),
            new MyBundle\MyBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}


Stehe grad n bisschen aufm Schlauch.
 

censored

Mitglied
Ok, also ich kenne Symfony halt überhaupt nicht, aber es scheint ja ein normales php framework zu sein, d.h. ich kann dir vielleicht trotzdem helfen. Wenn ich die Frage richtig verstehe, willst du einmal die Ergebnisse deines Projekts im Browser ansehen, stimmt das?
In diesem Fall muss ich zuerst fragen, ob überhaupt ein Webserver bei dir installiert ist, wenn nicht, dann sind noch ein paar Setups nötig. Ich empfehle übrigens Apache als Webserver.
 

Neue Themen


Oben