Symfony4 - Error: "Notice: Undefined index: dbname" in AbstractOracleDriver.php while trying to create database

symfony/error renderer
symfony exception listener
symfony fatal error
symfonycomponent errorhandler error fatalerror
symfony error log
symfony json error response
symfony error subscriber
symfony php errors

I am using Symfony 4.0.3 and I need connect to Oracle DB. I follow this instructions:

https://symfony.com/doc/current/doctrine.html

my .env file

DATABASE_URL=oci8://user:pwd@xxx.xxx.xxx.xxx:1521/something

host address is from tnsnames.ora -> HOST, something is from tnsnames.ora -> SERVICE_NAME

And after running command:

php bin/console doctrine:database:create

I get this error:

C:\Apache24\htdocs\myapp>
2018-01-25T12:58:47+00:00 [error] Error thrown while running command 
"doctrine:d
atabase:create". Message: "Notice: Undefined index: dbname"

In AbstractOracleDriver.php line 125:

  Notice: Undefined index: dbname

I am able to connect to DB by plain PHP, but through Symfony not. dbname is something from my connect url at .env file. This is set from tnsnames.ora.

It looks like the dbname parameter is not picked up from your environment variable / DBAL url.

To solve this quickly just use explicit configuration instead of URL for doctrine DBAL's configuration.

The full reference configuration can be found in the symfony documentation - Doctrine DBAL Reference Configuration

The documentation for the Doctrine DBAL Oracle configuration can be found here.

config/packages/doctrine.yaml:

doctrine:
  # [..]
  dbal:
    default_connection:   oracle_db_1
    connections:
      oracle_db_1:
        driver:    'oci8' # ... or 'pdo_oci'
        dbname:    '<dbname>'
        host:      '<host>'
        port:      '<port>'
        user:      '<user>'
        password:  '<password>'

If that works replace dbname, host, port etc. with container parameters (i.e. '%env(DATABASE_NAME)%') read from environment variables and add those to your .env file.

New in Symfony 4.4: ErrorHandler Component (Symfony Blog), An error handler to catch PHP errors and convert them into exceptions;; An exception handler to catch uncaught PHP exceptions and display nice  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Symfony Error: “An exception has been thrown during the rendering of a template”

doctrine.yaml edited like this:

parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
#env(DATABASE_URL): ''

doctrine:
    dbal:
      default_connection:   default
      connections:
        default:
          driver:    'oci8' # ... or 'pdo_oci'
          dbname:    'dbname'
          host:      'xxx.xxx.xxx.xxx'
          port:      '1521'
          user:      'user'
          password:  'pwd'

# With Symfony 3.3, remove the `resolve:` prefix
#         url: '%env(resolve:DATABASE_URL)%' 
orm:
    auto_generate_proxy_classes: '%kernel.debug%'
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true
    mappings:
        App:
            is_bundle: false
            type: annotation
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App

after command php bin/console doctrine:database:create

I have same error.

2018-01-26T06:23:31+00:00 [error] Error thrown while running command            "doctrine:d
atabase:create". Message: "Notice: Undefined index: dbname"

In AbstractOracleDriver.php line 125:

  Notice: Undefined index: dbname

my dbname is same as I have in SQL Developer in SID item.

symfony/error-handler: The ErrorHandler component , The ErrorHandler component provides tools to manage errors and ease debugging PHP code. Getting Started. $ composer require symfony/error-handler​. use  Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

There is a bug in doctrine/dbal version <= 2.8.0. Upgrade to doctrine/dbal to version 2.9.0 and it should start to work.

Here is the github pull request solving this issue: https://github.com/doctrine/dbal/pull/3297

Symfony4 'ERROR : Variable does not exist', when i call a variable , In this tutorial, we'll show you how to add native error handling in a Symfony 3 application so you can capture handled and unhandled errors. Symfony looks for message files (i.e. translations) in the following default locations: the translations/ directory (at the root of the project); the Resources/translations/ directory inside of any bundle. The locations are listed here with the highest priority first. That is, you can override the translation messages of a bundle in the first

If you use the SERVICE_NAME for your connection, you can define the DATABASE_URL like this:

    DATABASE_URL=oci8://user:pw@x.x.x.x:1521/?service=1&servicename=something&charset=AL32UTF8

Error Monitoring in Symfony, Get Symfony error monitoring with complete stack traces. See local variables in the stack for prod errors, just like in your dev environment. Symfony gives you several ways to customize how a form is rendered. In this article you'll learn how to make single customizations to one or more fields of your forms. If you need to customize all your forms in the same way, create instead a form theme or use any of the built-in themes, such as the Bootstrap theme for Symfony forms .

Symfony error tracking with Sentry, The ErrorHandler component provides tools to manage errors and ease debugging PHP code. Getting Started. $ composer require symfony/error  Configuring a Web Server¶ The preferred way to develop your Symfony application is to use Symfony Local Web Server. However, when running the application in the production environment, you'll need to use a fully-featured web server. This article describes several ways to use Symfony with Apache or Nginx.

symfony/error-handler, There are two types of errors: the simple message error that is usually given by the exception message and it will be display in the message key  Download the Symfony framework and Symfony components using Composer. Download Symfony source code from GitHub and the Symfony Demo application.

Symfony 4, The error started on ProgrammerControllerTest where we use assertResponsePropertiesExist() . Whoops! And there's the problem - I had  that is deprecated since Symfony 4.2, use {@see AbstractController} When using AbstractController we face this issue Service "fos_elastica.manager" not found: even though it exists in the app's container

Comments
  • Can you add your config/packages/doctrine.yaml to the question, please? You can debug doctrine's current configuration by running bin/console debug:container --parameters and inspecting the doctrine.* parameters.
  • This file was not changed. I was following that instructions.