[SF][Symfony4][SF4] EnumType in Form field |
[SF][Symfony4][SF4] EnumType in Form field |
23.10.2022, 22:15:10
Post
#1
|
|
Grupa: Zarejestrowani Postów: 496 Pomógł: 2 Dołączył: 15.07.2011 Skąd: Katowice Ostrzeżenie: (0%) |
Stworzyłem sobie typ Enum z wartościami:
dodałem go sobie do formularza :
i wydawało mi się że dobrze dodałem , zgodnie z dok.: https://symfony.com/doc/current/reference/f...types/enum.html ale niestety mam taki błąd: Expected to find class "App\Form\Enum\MeetName" in file "C:\xampp\htdocs\ligatyperow2\src/Form\Enum\MeetName.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used with the resource in C:\xampp\htdocs\ligatyperow2\config/services.yaml (which is loaded in resource "C:\xampp\htdocs\ligatyperow2\config/services.yaml"). co mam nie tak ? |
|
|
24.10.2022, 10:41:56
Post
#2
|
|
Grupa: Zarejestrowani Postów: 377 Pomógł: 70 Dołączył: 15.07.2014 Ostrzeżenie: (0%) |
Odpalałeś już czyszczenie cache?
Kod php bin/console c:c
|
|
|
24.10.2022, 21:40:34
Post
#3
|
|
Grupa: Zarejestrowani Postów: 496 Pomógł: 2 Dołączył: 15.07.2011 Skąd: Katowice Ostrzeżenie: (0%) |
|
|
|
24.10.2022, 22:39:59
Post
#4
|
|
Grupa: Zarejestrowani Postów: 377 Pomógł: 70 Dołączył: 15.07.2014 Ostrzeżenie: (0%) |
Pokaż jak wyglądają pliki: `services.yaml` i `composer.json`. Pokaż też strukturę katalogów.
|
|
|
24.10.2022, 22:45:37
Post
#5
|
|
Grupa: Zarejestrowani Postów: 621 Pomógł: 144 Dołączył: 22.12.2010 Ostrzeżenie: (0%) |
i napisz jaka wersje php masz
|
|
|
25.10.2022, 07:42:02
Post
#6
|
|
Grupa: Zarejestrowani Postów: 496 Pomógł: 2 Dołączył: 15.07.2011 Skąd: Katowice Ostrzeżenie: (0%) |
Wersja PHP:
C:\Users\czechdam>php -version PHP 7.4.29 (cli) (built: Apr 12 2022 20:21:18) ( ZTS Visual C++ 2017 x64 ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies Pracuje na Windows i Symfony wersja 4.4 Struktura katalogów: główny projekt: . .. .env .gitignore .idea bin composer-setup.php composer.json composer.lock config nbproject phpunit.xml.dist public src symfony symfony.lock templates tests translations var vendor cd src: . .. Command Controller DataFixtures Entity EventListener Exception Form Kernel.php Manager Migrations Repository Security Service Twig Util cd Form: . .. ChangePasswordType.php CommentType.php Enum LeagueType.php MeetType.php TeamType.php UserType.php cd Enum: . .. MeetName.php plik services.yaml: https://symfony.com/doc/current/best_practi...d-configuration parameters: services: # default configuration for services in *this* file _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: resource: '../src/*' exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' # controllers are imported separately to make sure services can be injected # as action arguments even if you don't extend any base controller class App\Controller\: resource: '../src/Controller' tags: ['controller.service_arguments'] # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones App\EventListener\ActivityListener: arguments: - '@security.token_storage' - '@doctrine.orm.entity_manager' tags: - { name: 'kernel.event_listener', event: 'kernel.controller', method: 'onCoreController' } App\EventListener\ResultListener: tags: - { name: doctrine.event_listener, event: postUpdate }"># This file is the entry point to configure your own services. # Files in the packages/ subdirectory configure your dependencies. # Put parameters here that don't need to change on each machine where the app is deployed # https://symfony.com/doc/current/best_practi...d-configuration parameters: services: # default configuration for services in *this* file _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: resource: '../src/*' exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' # controllers are imported separately to make sure services can be injected # as action arguments even if you don't extend any base controller class App\Controller\: resource: '../src/Controller' tags: ['controller.service_arguments'] # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones App\EventListener\ActivityListener: arguments: - '@security.token_storage' - '@doctrine.orm.entity_manager' tags: - { name: 'kernel.event_listener', event: 'kernel.controller', method: 'onCoreController' } App\EventListener\ResultListener: tags: - { name: doctrine.event_listener, event: postUpdate } plik composer.json: { "type": "project", "license": "proprietary", "require": { "php": "^7.1.3", "ext-ctype": "*", "ext-iconv": "*", "sensio/framework-extra-bundle": "^5.1", "stof/doctrine-extensions-bundle": "^1.3", "symfony/asset": "4.3.*", "symfony/console": "4.3.*", "symfony/dotenv": "4.3.*", "symfony/expression-language": "4.3.*", "symfony/flex": "^1.3.1", "symfony/form": "4.4.2", "symfony/framework-bundle": "4.4.0", "symfony/http-client": "4.4.*", "symfony/intl": "4.4.*", "symfony/monolog-bundle": "^3.1", "symfony/orm-pack": "^1.0", "symfony/process": "4.3.*", "symfony/security-bundle": "4.4.0", "symfony/serializer-pack": "*", "symfony/swiftmailer-bundle": "^3.1", "symfony/translation": "4.4.*", "symfony/twig-bundle": "4.4.*", "symfony/validator": "4.4.*", "symfony/web-link": "4.3.*", "symfony/yaml": "4.3.*" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.4", "symfony/debug-bundle": "^4.4", "symfony/maker-bundle": "^1.12", "symfony/phpunit-bridge": "^5.0", "symfony/stopwatch": "^4.4", "symfony/test-pack": "*", "symfony/var-dumper": "^4.4", "symfony/web-profiler-bundle": "^4.4.2", "symfony/web-server-bundle": "4.3.*" }, "config": { "preferred-install": { "*": "dist" }, "sort-packages": true, "allow-plugins": { "symfony/flex": 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.4.2" } } } |
|
|
25.10.2022, 08:37:21
Post
#7
|
|
Grupa: Zarejestrowani Postów: 377 Pomógł: 70 Dołączył: 15.07.2014 Ostrzeżenie: (0%) |
Enumy są od wersji PHP 8.1 dostępne. Ty masz 7.4 - dlatego to nie działa.
Przepisz klasę enum na consty. Możesz też użyć jednej z dostępnych bibliotek: - https://github.com/myclabs/php-enum - https://github.com/spatie/enum Jest ich więcej, ale z tego co czytałem, to powyższe są najpopularniejsze i napisz jaka wersje php masz Skąd wiedziałeś, że wersja PHP może być przyczyną? Ten post edytował Salvation 25.10.2022, 08:28:48 |
|
|
25.10.2022, 09:46:57
Post
#8
|
|
Grupa: Zarejestrowani Postów: 621 Pomógł: 144 Dołączył: 22.12.2010 Ostrzeżenie: (0%) |
Skąd wiedziałeś, że wersja PHP może być przyczyną? Ścieżki się zgadzały, nazwy klas itp, ale był problem z "Expected to find class", no i faktycznie klasy żadnej tam nie ma, tylko enum którego php nie rozumie, więc wydedukowałem że to może być problem. Swoją drogą, z tego co widzę to EnumType w symfony pojawił się w wersji 5.4 także to też będzie pewnie generowało problemy. |
|
|
25.10.2022, 20:41:39
Post
#9
|
|
Grupa: Zarejestrowani Postów: 3 034 Pomógł: 366 Dołączył: 24.05.2012 Ostrzeżenie: (0%) |
Po pierwsze używaj bbcodes, po drugie skoro:
Cytat Symfony wersja 4.4 To czemu wgl przeglądasz dokumentacje dla 5.4 i więcej? >W 4.4 nie ma EnumTypes wcale |
|
|
25.10.2022, 21:38:35
Post
#10
|
|
Grupa: Zarejestrowani Postów: 496 Pomógł: 2 Dołączył: 15.07.2011 Skąd: Katowice Ostrzeżenie: (0%) |
Dzięki Panowie. Faktycznie zabrałem się do tego jak pies do jeża.
Zrobiłem na razie tak:
Muszę chyba jak najszybciej przenieść się na wersję 5.4 albo nawet 6.0 Ten post edytował damianooo 25.10.2022, 21:39:02 |
|
|
Wersja Lo-Fi | Aktualny czas: 27.09.2024 - 01:51 |