Symfony2无法创建数据库无法找到驱动程序(pdo)

时间:2015-06-17 02:29:57

标签: php mysql symfony pdo doctrine-orm

请帮助我,我正在做Symblog教程,遗憾的是这些教程充满了错误,所以我需要寻求你的智慧。我在教程的一部分,我需要使用2个命令

$ php app / console doctrine:database:create

$ php app / console doctrine:schema:create

但在我使用第一个后​​,我在cli中出现红色错误:

Could not create database `symblog_db` for connection named default
could not find driver

我检查了另一个主题,他们说我必须确保我的apache和cli使用相同的php.ini文件。我查了一下 - 他们不是,所以现在呢?从cli复制php.ini并用一种或其他方式覆盖apache?

我在Ubuntu上使用XAMPP

这是/opt/lampp/etc/php.ini

的扩展部分
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_ming.dll
;extension=php_mssql.dll
extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll

;extension="zip.so"

;extension="sqlite.so"

;extension="radius.so"

;extension="pgsql.so"

; disabled in XAMPP 1.7.2 because incompatible with PHP 5.3.0
;extension="dbx.so"

;extension="ming.so"

;extension="ncurses.so"

;extension="dio.so"

;extension="interbase.so"

; disabled in XAMPP 1.7.2 because incompatible with PHP 5.3.0
;extension="eaccelerator.so"
;eaccelerator.shm_size="16"
;eaccelerator.cache_dir="/opt/lampp/temp/eaccelerator"
;eaccelerator.enable="1"
;eaccelerator.optimizer="1"
;eaccelerator.check_mtime="1"
;eaccelerator.debug="0"
;eaccelerator.filter=""
;eaccelerator.shm_max="0"
;eaccelerator.shm_ttl="0"
;eaccelerator.shm_prune_period="0"
;eaccelerator.shm_only="0"
;eaccelerator.compress="1"
;eaccelerator.compress_level="9"

/etc/php5/cli/php.ini似乎没有任何扩展名。

这是我的app / config / parameters.yml(显然我把真正的密码放在我的文件中)

    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: null
    database_name: symblog_db
    database_user: root
    database_password: null

    mailer_transport: "gmail"
    mailer_encryption: "ssl"
    mailer_auth_mode: "login"
    mailer_host: "smtp.gmail.com"
    mailer_user: "mactestsymblog@gmail.com"
    mailer_password: "xxxxxxxxx"

    secret: JaTylkoTrenuje

和app / config / config.yml

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: @BloggerBlogBundle/Resources/config/config.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: en

framework:
    #esi:             ~
    #translator:      { fallbacks: ["%locale%"] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    #serializer:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"

# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        #yui_css:
        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%" 
        charset: UTF8

        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #     path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

我可以添加phpinfo,但它会超出允许的长度问题。请帮帮我。

2 个答案:

答案 0 :(得分:0)

看起来你应该解开字符串“extension = php_pdo_mysql.dll”。 当cli和http使用不同的.ini文件时 - 它不是问题,它是具有不同首选项的不同环境。 但我不明白,如果你使用Ubuntu,为什么扩展名有.dll扩展名。

答案 1 :(得分:-1)

我取消注释了这一行extension=php_pdo_mysql.dll,它对我有用..