Подтвердить что ты не робот

Server: run Exception В поле "сервер" отсутствуют команды, определенные

Когда я запускаю сервер с помощью php bin/console server:run, я получаю следующую ошибку. There are no commands defined in the "server" namespace.

Когда я запускаю команду php bin/console, я делаю следующий вывод. Что не отображает сервер: команды.

Symfony 3.3.0-DEV (kernel: app, env: dev, debug: true)

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env=ENV         The environment name [default: "dev"]
      --no-debug        Switches off debug mode
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about                                   Displays information about the current project
  help                                    Displays help for a command
  list                                    Lists commands
 app
  app:download-beameemail                 download beame emails.
  app:download-businessunits              download businessunits.
  app:download-drivers                    download drivers.
  app:download-fleets                     download fleets.
  app:download-fmpositions                download fm_positions.
  app:download-fmtrips                    download fm_trips.
  app:download-fmunits                    download fm_units.
  app:download-skypositions               download skytrack_positions.
  app:download-skyunits                   download skytrack_units.
  app:download-vehicles                   download vehicles.
 assets
  assets:install                          Installs bundles web assets under a public web directory
 cache
  cache:clear                             Clears the cache
  cache:pool:clear                        Clears cache pools
  cache:warmup                            Warms up an empty cache
 config
  config:dump-reference                   Dumps the default configuration for an extension
 debug
  debug:config                            Dumps the current configuration for an extension
  debug:container                         Displays current services for an application
  debug:event-dispatcher                  Displays configured listeners for an application
  debug:router                            Displays current routes for an application
  debug:swiftmailer                       [swiftmailer:debug] Displays current mailers for an application
  debug:translation                       Displays translation messages information
  debug:twig                              Shows a list of twig functions, filters, globals and tests
 doctrine
  doctrine:cache:clear-collection-region  Clear a second-level cache collection region.
  doctrine:cache:clear-entity-region      Clear a second-level cache entity region.
  doctrine:cache:clear-metadata           Clears all metadata cache for an entity manager
  doctrine:cache:clear-query              Clears all query cache for an entity manager
  doctrine:cache:clear-query-region       Clear a second-level cache query region.
  doctrine:cache:clear-result             Clears result cache for an entity manager
  doctrine:database:create                Creates the configured database
  doctrine:database:drop                  Drops the configured database
  doctrine:database:import                Import SQL file(s) directly to Database.
  doctrine:ensure-production-settings     Verify that Doctrine is properly configured for a production environment.
  doctrine:generate:crud                  [generate:doctrine:crud] Generates a CRUD based on a Doctrine entity
  doctrine:generate:entities              [generate:doctrine:entities] Generates entity classes and method stubs from your mapping information
  doctrine:generate:entity                [generate:doctrine:entity] Generates a new Doctrine entity inside a bundle
  doctrine:generate:form                  [generate:doctrine:form] Generates a form type class based on a Doctrine entity
  doctrine:mapping:convert                [orm:convert:mapping] Convert mapping information between supported formats.
  doctrine:mapping:import                 Imports mapping information from an existing database
  doctrine:mapping:info                   
  doctrine:query:dql                      Executes arbitrary DQL directly from the command line.
  doctrine:query:sql                      Executes arbitrary SQL directly from the command line.
  doctrine:schema:create                  Executes (or dumps) the SQL needed to generate the database schema
  doctrine:schema:drop                    Executes (or dumps) the SQL needed to drop the current database schema
  doctrine:schema:update                  Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.
  doctrine:schema:validate                Validate the mapping files.
 fos
  fos:js-routing:debug                    Displays currently exposed routes for an application
  fos:js-routing:dump                     Dumps exposed routes to the filesystem
 generate
  generate:bundle                         Generates a bundle
  generate:command                        Generates a console command
  generate:controller                     Generates a controller
 lint
  lint:twig                               Lints a template and outputs encountered errors
  lint:xliff                              Lints a XLIFF file and outputs encountered errors
  lint:yaml                               Lints a file and outputs encountered errors
 router
  router:match                            Helps debug routes by simulating a path info match
 security
  security:check                          Checks security issues in your project dependencies
  security:encode-password                Encodes a password.
 swiftmailer
  swiftmailer:email:send                  Send simple email message
  swiftmailer:spool:send                  Sends emails from the spool
 translation
  translation:update                      Updates the translation file

Я попытался исправить это, запустив composer require symfony/symfony и composer update, но он все еще не отображается. Есть ли что-нибудь еще, что я могу попробовать?

Изменить ниже - это моя php-информация от php -version

PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

ИЗМЕНИТЬ 2

существует каталог vendor\symfon\symfony\src\Symfony\Bundle\FrameworkBundle\Command и содержит следующие файлы

AboutCommand.php
AbstractConfigCommand.php
AssetsInstallCommand.php
CacheClearCommand.php
CachePoolClearCommand.php
CacheWarmupCommand.php
ConfigDebugCommand.php
ConfigDumpReferenceCommand.php
ContainerAwareCommand.php
ContainerDebugCommand.php
EventDispatcherDebugCommand.php
RouterDebugCommand.php
RouterMatchCommand.php
TranslationDebugCommand.php
TranslationUpdateCommand.php
WorkflowDumpCommand.php
XliffLintCommand.php
YamlLintCommand.php
4b9b3361

Ответ 1

Как я упоминал в своем комментарии, в S3.3 серверные команды были перемещены в свой собственный WebServerBundle. Для активации пакета требуется некоторое редактирование AppKernel.php. Я подозреваю, что многие другие разработчики могут столкнуться с этим, как только 3.3 действительно выпущен, и люди пытаются модернизировать.

Я не обещаю, но попробуйте обновить AppKernel.php с помощью:

    if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
        $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
        $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();

        if ('dev' === $this->getEnvironment()) {
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
        }
    }

У меня нет хорошего тестового проекта, чтобы попробовать, но, по крайней мере, команды должны появиться.

И в случае, если кто-то задается вопросом, все, что я делал, это установить новый проект разработки и немного подтолкнуть.

composer create-project symfony/framework-standard-edition s33 "3.3.*" --stability=dev

Я также нашел это, но он не упоминает о необходимости обновления AppKernel.php http://symfony.com/blog/new-in-symfony-3-3-webserverbundle

Из руководства по обновлению: https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.3.md

Команды server: run, server: start, server: stop и server: status console были перемещены в выделенный пакет. Требовать symfony/web-server-bundle в вашем composer.json и зарегистрировать Symfony\Bundle\WebServerBundle\WebServerBundle в вашем AppKernel, чтобы использовать их.

Пока у вашего композитора.json есть symfony/symfony, тогда нет необходимости добавлять к нему пакет веб-серверов. Просто нужно настроить файл AppKernel.

Ответ 2

выполните эту команду перед запуском сервера.

composer require symfony/web-server-bundle --dev

Ответ 3

вы должны выполнить эту команду:

composer req webserver

Ответ 4

Тип:

php bin/console

Вы увидите все разрешенные команды.

Если вы хотите использовать команды сервера, вы должны установить его в свой проект:

композитору требуется сервер --dev

снова запустить

php bin/console

и вы должны уметь его видеть и использовать.

Ответ 5

Убедитесь, что в среде установлен правильный APP_ENV. В моем случае это было критично.

Ответ 6

Как говорит @Barh, в вашем файле .env должен быть APP_ENV=dev.

В противном случае Symfony 4 не будет работать в режиме разработки.

Ответ 7

обновление с symfony <3.3 до symfony> 3.3 вызовет эту проблему, потому что веб-сервер был извлечен в отдельный пакет.

поэтому вам потребуется этот пакет:

composer require symfony/web-server-bundle --dev

и в вашем AppKernel

 if ('dev' === $this->getEnvironment()) {
        $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
    }

для получения дополнительной информации: проверьте здесь

Ответ 8

  1. Отключение справки брандмауэра
  2. работает...... композитор очистить кеш помог в разрешении разрешений
  3. работает...... composer req webserver помог очистить мои команды, определенные в пространстве имен "server"

Ответ 9

Удалите файл env.local, если он у вас есть.

Reson: Потому что сервер: запуск не выполняется в производственной среде

Ответ 10

У меня была .env же проблема на Symfony 4 после переключения в .env на prod. Некоторые команды не видны на Prod.

Вам нужно либо перейти на dev, либо: bin/console --env=dev

И так, чтобы запустить сервер: bin/console --env=dev server:run 0.0.0.0:8005

Ответ 11

Для Symfony 4 и более вы должны набрать php -S 127.0.0.1:8000 -t public чтобы запустить сервер