我一直在尝试将我的symfony2应用程序部署到Heroku,并且我一直在遇到这些错误。我整个星期都在研究这个问题。有人请告诉我我做错了什么。我将包含一些重要文件。如果您需要我包含其他任何内容,请与我们联系。谢谢!
特别是这4个错误:
[学说\ DBAL \异常\ ConnectionException]
驱动程序中发生异常:SQLSTATE [HY000] [2002]没有这样的文件或 目录[Doctrine \ DBAL \ Driver \ PDOException] SQLSTATE [HY000] [2002]没有这样的文件或目录
[PDOException]
SQLSTATE [HY000] [2002]没有这样的文件或目录脚本 SENSIO \包\ DistributionBundle \作曲\ ScriptHandler :: installAssets 处理以异常终止的post-install-cmd事件
这是我的composer.json文件:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/", "SymfonyStandard": "app/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.5",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"doctrine/doctrine-migrations-bundle": "dev-master",
"doctrine/migrations": "dev-master",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"ircmaxell/password-compat": "~1.0.3",
"friendsofsymfony/user-bundle": "~1.3"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"phpunit/phpunit": "3.7.*"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.5-dev"
}
}
}
这是我的appKernel.php文件
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function __construct($environment, $debug){
date_default_timezone_set( 'America/Chicago' );
parent::__construct($environment, $debug);
}
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Foodoo\Bundle\FoodooBundle\FoodooFoodooBundle(),
new Blogger\BlogBundle\BloggerBlogBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Blogger\UserBundle\BloggerUserBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}
这是我的config.yml文件:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: @BloggerBlogBundle/Resources/config/config.yml }
framework:
#esi: ~
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { 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: [BloggerBlogBundle]
#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: "%database_driver%"
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%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
encryption: ssl
# spool: { type: memory }
# configuration for fos user bundle
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: demo_fos_login
user_class: Blogger\UserBundle\Entity\User
这是来自heroku的错误日志:
-----> PHP app detected
-----> Resolved composer.lock requirement for PHP to version 5.6.4.
-----> Installing system packages...
- PHP 5.6.4
- Apache 2.4.10
- Nginx 1.6.0
-----> Installing PHP extensions...
- zend-opcache (automatic; bundled)
-----> Installing dependencies...
Composer version 1.0.0-alpha9 2014-12-07 17:15:20
Loading composer repositories with package information
Installing dependencies from lock file
- Installing doctrine/lexer (v1.0)
Downloading: connection... Downloading: 0% Downloading: 80% Downloading: 100%
- Installing doctrine/annotations (v1.2.3)
Downloading: connection... Downloading: 0% Downloading: 10% Downloading: 20% Downloading: 30% Downloading: 40% Downloading: 50% Downloading: 60% Downloading: 70% Downloading: 80% Downloading: 90% Downloading: 100%
- Installing twig/twig (v1.16.3)
Downloading: connection... Downloading: 0% Downloading: 5% Downloading: 10% Downloading: 15% Downloading: 20% Downloading: 25% Downloading: 30% Downloading: 35% Downloading: 40% Downloading: 45% Downloading: 50% Downloading: 55% Downloading: 60% Downloading: 65% Downloading: 70% Downloading: 75% Downloading: 80% Downloading: 85% Downloading: 90% Downloading: 95% Downloading: 100% Downloading: 100%
- Installing psr/log (1.0.0)
Downloading: connection... Downloading: 0% Downloading: 15% Downloading: 30% Downloading: 45% Downloading: 60% Downloading: 75% Downloading: 100%
- Installing doctrine/inflector (v1.0.1)
Downloading: connection... Downloading: 0% Downloading: 60% Downloading: 100%
- Installing doctrine/collections (v1.2)
Downloading: connection... Downloading: 0% Downloading: 35% Downloading: 70% Downloading: 100%
- Installing doctrine/cache (v1.3.1)
Downloading: connection... Downloading: 0% Downloading: 20% Downloading: 25% Downloading: 40% Downloading: 45% Downloading: 65% Downloading: 85% Downloading: 100%
- Installing doctrine/common (v2.4.2)
Downloading: connection... Downloading: 0% Downloading: 5% Downloading: 10% Downloading: 15% Downloading: 20% Downloading: 25% Downloading: 30% Downloading: 35% Downloading: 40% Downloading: 45% Downloading: 50% Downloading: 55% Downloading: 60% Downloading: 65% Downloading: 70% Downloading: 75% Downloading: 80% Downloading: 85% Downloading: 90% Downloading: 95% Downloading: 100%
- Installing symfony/symfony (v2.6.1)
Downloading: connection... Downloading: 0% Downloading: 5% Downloading: 10% Downloading: 15% Downloading: 20% Downloading: 25% Downloading: 30% Downloading: 35% Downloading: 40% Downloading: 45% Downloading: 50% Downloading: 55% Downloading: 60% Downloading: 65% Downloading: 70% Downloading: 75% Downloading: 80% Downloading: 85% Downloading: 90% Downloading: 95% Downloading: 100% Downloading: 100%
- Installing doctrine/doctrine-cache-bundle (v1.0.1)
Downloading: connection... Failed to download doctrine/doctrine-cache-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/doctrine-cache-bundle (v1.0.1)
Cloning e4b6f810aa047f9cbfe41c3d6a3d7e83d7477a9d
- Installing jdorn/sql-formatter (v1.2.17)
Downloading: connection... Failed to download jdorn/sql-formatter from dist: Could not authenticate against github.com
Now trying to download from source
- Installing jdorn/sql-formatter (v1.2.17)
Cloning 64990d96e0959dff8e059dfcdc1af130728d92bc
- Installing doctrine/dbal (v2.5.0)
Downloading: connection... Failed to download doctrine/dbal from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/dbal (v2.5.0)
Cloning 71140662c0a954602e81271667b6e03d9f53ea34
Skipped installation of bin bin/doctrine-dbal for package doctrine/dbal: name conflicts with an existing file
- Installing doctrine/doctrine-bundle (v1.3.0)
Downloading: connection... Failed to download doctrine/doctrine-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/doctrine-bundle (v1.3.0)
Cloning 3beb3a780485ab01f86941f4892cd23ef8c39c6b
- Installing doctrine/data-fixtures (v1.0.0)
Downloading: connection... Failed to download doctrine/data-fixtures from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/data-fixtures (v1.0.0)
Cloning b4a135c7db56ecc4602b54a2184368f440cac33e
- Installing doctrine/doctrine-fixtures-bundle (v2.2.0)
Downloading: connection... Failed to download doctrine/doctrine-fixtures-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/doctrine-fixtures-bundle (v2.2.0)
Cloning c811f96f0cf83b997e3a3ed037cac729bbe3e803
- Installing doctrine/migrations (dev-master 96f838b)
Downloading: connection... Failed to download doctrine/migrations from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/migrations (dev-master 96f838b)
Cloning 96f838b4fa93693d19196c8e24ed5f1c3972ba87
- Installing doctrine/doctrine-migrations-bundle (dev-master 81575a4)
Downloading: connection... Failed to download doctrine/doctrine-migrations-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/doctrine-migrations-bundle (dev-master 81575a4)
Cloning 81575a4316951125ce408c70f30547c77d98f78a
- Installing doctrine/orm (v2.4.7)
Downloading: connection... Failed to download doctrine/orm from dist: Could not authenticate against github.com
Now trying to download from source
- Installing doctrine/orm (v2.4.7)
Cloning 2bc4ff3cab2ae297bcd05f2e619d42e6a7ca9e68
Skipped installation of bin bin/doctrine for package doctrine/orm: name conflicts with an existing file
Skipped installation of bin bin/doctrine.php for package doctrine/orm: name conflicts with an existing file
- Installing friendsofsymfony/user-bundle (v1.3.5)
Downloading: connection... Failed to download friendsofsymfony/user-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing friendsofsymfony/user-bundle (v1.3.5)
Cloning d66890ad3489e18be153502c5ccc3f2bf5cce442
- Installing incenteev/composer-parameter-handler (v2.1.0)
Downloading: connection... Failed to download incenteev/composer-parameter-handler from dist: Could not authenticate against github.com
Now trying to download from source
- Installing incenteev/composer-parameter-handler (v2.1.0)
Cloning 143272a0a09c62616a3c8011fc165a10c6b35241
- Installing ircmaxell/password-compat (v1.0.4)
Downloading: connection... Failed to download ircmaxell/password-compat from dist: Could not authenticate against github.com
Now trying to download from source
- Installing ircmaxell/password-compat (v1.0.4)
Cloning 5c5cde8822a69545767f7c7f3058cb15ff84614c
- Installing sensiolabs/security-checker (v2.0.0)
Downloading: connection... Failed to download sensiolabs/security-checker from dist: Could not authenticate against github.com
Now trying to download from source
- Installing sensiolabs/security-checker (v2.0.0)
Cloning 5b4eb4743ebe68276c911c84101ecdf4a9ae76ee
Skipped installation of bin security-checker for package sensiolabs/security-checker: name conflicts with an existing file
- Installing sensio/distribution-bundle (v3.0.14)
Downloading: connection... Failed to download sensio/distribution-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing sensio/distribution-bundle (v3.0.14)
Cloning dc20d5ab3251587b047859ca2fc06c1b88a38d00
- Installing sensio/framework-extra-bundle (v3.0.4)
Downloading: connection... Failed to download sensio/framework-extra-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing sensio/framework-extra-bundle (v3.0.4)
Cloning b3bc3e67c8b6b68b18d727012183520d35ee762a
- Installing kriswallsmith/assetic (v1.2.1)
Downloading: connection... Failed to download kriswallsmith/assetic from dist: Could not authenticate against github.com
Now trying to download from source
- Installing kriswallsmith/assetic (v1.2.1)
Cloning b20efe38845d20458702f97f3ff625d80805897b
- Installing symfony/assetic-bundle (v2.5.0)
Downloading: connection... Failed to download symfony/assetic-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing symfony/assetic-bundle (v2.5.0)
Cloning 90ea7fb66d6d5245fd4afc16e4c8070214254fec
- Installing monolog/monolog (1.12.0)
Downloading: connection... Failed to download monolog/monolog from dist: Could not authenticate against github.com
Now trying to download from source
- Installing monolog/monolog (1.12.0)
Cloning 1fbe8c2641f2b163addf49cc5e18f144bec6b19f
- Installing symfony/monolog-bundle (v2.7.0)
Downloading: connection... Failed to download symfony/monolog-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing symfony/monolog-bundle (v2.7.0)
Cloning e8f71c91a3784f3fa1a75fb1f7f4d4826c5f2773
- Installing swiftmailer/swiftmailer (v5.3.1)
Downloading: connection... Failed to download swiftmailer/swiftmailer from dist: Could not authenticate against github.com
Now trying to download from source
- Installing swiftmailer/swiftmailer (v5.3.1)
Cloning c5f963e7f9d6f6438fda4f22d5cc2db296ec621a
- Installing symfony/swiftmailer-bundle (v2.3.8)
Downloading: connection... Failed to download symfony/swiftmailer-bundle from dist: Could not authenticate against github.com
Now trying to download from source
- Installing symfony/swiftmailer-bundle (v2.3.8)
Cloning 970b13d01871207e81d17b17ddda025e7e21e797
- Installing twig/extensions (v1.2.0)
Downloading: connection... Failed to download twig/extensions from dist: Could not authenticate against github.com
Now trying to download from source
- Installing twig/extensions (v1.2.0)
Cloning 8cf4b9fe04077bd54fc73f4fde83347040c3b8cd
Generating optimized autoload files
Updating the "app/config/parameters.yml" file
Clearing the cache for the prod environment with debug false
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] No such file or directory
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'assets:install '\''web'\'''" command.
! Push rejected, failed to compile PHP app
答案 0 :(得分:2)
好像你没有将cleardb插件添加到你的heroku实例中
heroku addons:add cleardb:ignite
答案 1 :(得分:2)
以下是我为解决此问题所采取的措施:
我的config_prod.yml
文件导入了我的config.yml
文件,该文件导入了parameters.yml
文件,其中包含我本地服务器的数据库配置信息。
当您将其上传到实时服务器(heroku或任何其他服务器)时,您需要为新数据库配置parameters.yml
文件。
选项1(简单修复):
您可以在parameters.yml文件中更改数据库配置,以匹配heroku的cleardb:ignite
数据库。但除非您更改数据库配置信息,否则它将无法在您的本地服务器上运行。
选项2:
您可以创建另一个parameters.yml
文件并将其命名为不同的文件。即production_parmaeters.yml
,并在config_prod.yml
文件中导入该文件。并确保您的c onfig_dev.yml
文件包含原始parameters.yml
文件,其中包含您的本地开发数据库配置。
然后删除
- { resource: parameters.yml }
在您的主config.yml
文件中。
谢谢你们的帮助!
答案 2 :(得分:0)
如果您只是在Google上搜索“SQLSTATE [HY000] [2002]无此类文件或目录”消息,您将很快找到解释:通过Unix域套接字与MySQL的连接失败,因为该套接字,例如/var/sock/mysql.sock
,不存在(如果您尝试连接到localhost
,则MySQL会这样做,而如果您连接到127.0.0.1
,它会使用TCP / IP套接字。)
然后,您的问题很可能是您在某处为prod
环境设置了数据库凭据,但这些凭据无效,因为它们尝试连接到localhost
MySQL。