Autor Wątek: Początkowy projekt  (Przeczytany 57 razy)

Marcin1

  • Newbie
  • *
  • Wiadomości: 2
    • Zobacz profil
Początkowy projekt
« dnia: Marzec 12, 2019, 11:42:01 »
Cześć zaczynam projekt według tego na stronie Symfony. Startowy projekt


config/routes.yaml                               Później routes będę podawał przy akcjach
app_lucky_number:
    path: /lucky/number
    controller: App\Controller\LuckyController::number

src/Controller/LuckyController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;

class LuckyController
{
public function number()
{
$number1 = 5;

return new Response(
'<html><body>Numer: '.$number1.'</body></html>'
);
}
}

localhost:8000/lucky/number

 (2/2) LoaderLoadException

The autoloader expected class "App\Controller\LuckyController" to be defined in file "/home/pc/projekt/vendor/composer/../../src/Controller/LuckyController.php". The file was found but the class was not in it, the class name or namespace probably has a typo in /home/pc/projekt/config/services.yaml (which is loaded in resource "/home/pc/projekt/config/services.yaml").
in FileLoader.php line 166
at FileLoader->doImport('/home/pc/projekt/config/services.yaml', null, false, null)in FileLoader.php line 90
at FileLoader->import('/home/pc/projekt/config/services.yaml')in GlobFileLoader.php line 27
at GlobFileLoader->load('/home/pc/projekt/config/{services}.{php,xml,yaml,yml}', 'glob')in DelegatingLoader.php line 40
at DelegatingLoader->load('/home/pc/projekt/config/{services}.{php,xml,yaml,yml}', 'glob')in Kernel.php line 36
at Kernel->configureContainer(object(ContainerBuilder), object(DelegatingLoader))in MicroKernelTrait.php line 80
at Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}(object(ContainerBuilder))in ClosureLoader.php line 38
at ClosureLoader->load(object(Closure), null)in DelegatingLoader.php line 40
at DelegatingLoader->load(object(Closure))in MicroKernelTrait.php line 83
at Kernel->registerContainerConfiguration(object(DelegatingLoader))in Kernel.php line 653
at Kernel->buildContainer()in Kernel.php line 543
at Kernel->initializeContainer()in Kernel.php line 133
at Kernel->boot()in Kernel.php line 193
at Kernel->handle(object(Request))in index.php line 25
(1/2) RuntimeException

The autoloader expected class "App\Controller\LuckyController" to be defined in file "/home/pc/projekt/vendor/composer/../../src/Controller/LuckyController.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
in DebugClassLoader.php line 212
at DebugClassLoader->checkClass('App\\Controller\\LuckyController', '/home/pc/projekt/vendor/composer/../../src/Controller/LuckyController.php')in DebugClassLoader.php line 169
at DebugClassLoader->loadClass('App\\Controller\\LuckyController')
at spl_autoload_call('App\\Controller\\LuckyController')
at class_exists('App\\Controller\\LuckyController')in ClassExistenceResource.php line 76
at ClassExistenceResource->isFresh(0)in ContainerBuilder.php line 351
at ContainerBuilder->getReflectionClass('App\\Controller\\LuckyController')in FileLoader.php line 149
at FileLoader->findClasses('App\\', '../src/*', array('../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'))in FileLoader.php line 57
at FileLoader->registerClasses(object(Definition), 'App\\', '../src/*', '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}')in YamlFileLoader.php line 554
at YamlFileLoader->parseDefinition('App\\', array('resource' => '../src/*', 'exclude' => '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'), '/home/pc/projekt/config/services.yaml', array('autowire' => true, 'autoconfigure' => true))in YamlFileLoader.php line 229
at YamlFileLoader->parseDefinitions(array('parameters' => array('locale' => 'en'), 'services' => array('App\' => array('resource' => '../src/*', 'exclude' => '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'), 'App\Controller\' => array('resource' => '../src/Controller', 'tags' => array('controller.service_arguments')))), '/home/pc/projekt/config/services.yaml')in YamlFileLoader.php line 150
at YamlFileLoader->load('/home/pc/projekt/config/services.yaml', null)in FileLoader.php line 151
at FileLoader->doImport('/home/pc/projekt/config/services.yaml', null, false, null)in FileLoader.php line 90
at FileLoader->import('/home/pc/projekt/config/services.yaml')in GlobFileLoader.php line 27
at GlobFileLoader->load('/home/pc/projekt/config/{services}.{php,xml,yaml,yml}', 'glob')in DelegatingLoader.php line 40
at DelegatingLoader->load('/home/pc/projekt/config/{services}.{php,xml,yaml,yml}', 'glob')in Kernel.php line 36

In FileLoader.php line 166:
                                                                                                                                                         
  The autoloader expected class "App\Controller\LuckyController" to be defined in file "/home/pc/Religia/vendor/composer/../../src/Controller/LuckyController.php". The file was found but the class was not in it, the class name or namespace probably has a typo in /home/pc/Religia/config/services.yaml (which is loaded in resource "/home/pc/Religia/config/services.yaml").                                                                                   
                                                                                                                                                         

In DebugClassLoader.php line 212:
                                                                                                                                                         
  The autoloader expected class "App\Controller\LuckyController" to be defined in file "/home/pc/Religia/vendor/composer/../../src/Controller/LuckyController.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

Pewnie dobrze wiecie co robić? Macie jakąś podpowiedź?

« Ostatnia zmiana: Marzec 12, 2019, 17:14:05 wysłana przez Marcin1 »

Valantir

  • Global Moderator
  • Hero Member
  • *****
  • Wiadomości: 590
    • Zobacz profil
Odp: Początkowy projekt
« Odpowiedź #1 dnia: Marzec 12, 2019, 17:16:41 »
Podaj proszę zawartość pliku composer.json

Marcin1

  • Newbie
  • *
  • Wiadomości: 2
    • Zobacz profil
Odp: Początkowy projekt
« Odpowiedź #2 dnia: Marzec 13, 2019, 00:03:22 »
{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "sensio/framework-extra-bundle": "^5.1",
        "symfony/asset": "4.2.*",
        "symfony/console": "4.2.*",
        "symfony/dotenv": "4.2.*",
        "symfony/expression-language": "4.2.*",
        "symfony/flex": "^1.1",
        "symfony/form": "4.2.*",
        "symfony/framework-bundle": "4.2.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/orm-pack": "*",
        "symfony/process": "4.2.*",
        "symfony/security-bundle": "4.2.*",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/translation": "4.2.*",
        "symfony/twig-bundle": "4.2.*",
        "symfony/validator": "4.2.*",
        "symfony/web-link": "4.2.*",
        "symfony/yaml": "4.2.*"
    },
    "require-dev": {
        "symfony/debug-pack": "*",
        "symfony/maker-bundle": "^1.0",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "*",
        "symfony/web-server-bundle": "4.2.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "4.2.*"
        }
    }
}

Masz jakiś pomysł?
« Ostatnia zmiana: Marzec 13, 2019, 21:02:58 wysłana przez Marcin1 »

Valantir

  • Global Moderator
  • Hero Member
  • *****
  • Wiadomości: 590
    • Zobacz profil
Odp: Początkowy projekt
« Odpowiedź #3 dnia: Marzec 14, 2019, 19:37:02 »
Może głupie pytanie ale masz na początku pliku:

<?php