Doctrine error: "Failed opening required '/tmp/__CG__Source.php' "

Jorr.it

I am trying to migrate my PHP application to an Ubuntu server, but without succes. Any help would be appreciated.

First I installed Doctrine successfully into /jorrit/myapp, following the first part of Doctrine's Getting Started manual (till "Generating the Database Schema"). Secondly I placed my PHP scripts (which use Doctrine) in folder /jorrit/myapp.

When I try to run my PHP script in the CLI, I get this error messages:

PHP Warning: require(/tmp/__CG__Source.php): failed to open stream: No such file or directory in /jorrit/myapp/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 200

PHP Fatal error: require(): Failed opening required '/tmp/__CG__Source.php' (include_path='.:/usr/share/php:/usr/share/pear') in /jorrit/myapp/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 200

Bootstrap.php looks like this:

<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

require_once "vendor/autoload.php";

// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = false;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);

// the connection configuration
$dbParams = array(
        'driver'   => 'pdo_mysql',
        'host'     => 'xx',
        'user'     => 'xx',
        'password' => 'xx',
        'dbname'   => 'xx',
        'profiler' => 'false'
);


// obtaining the entity manager
$entityManager = EntityManager::create($dbParams, $config);

?>

The first lines of my PHP script:

<?php

require_once "bootstrap.php";
require_once 'classes.php';

$connection = $entityManager->getConnection();

The application works fine in my development environment (Windows). The /tmp folder exists and is accessible. The database is migrated succesfully and exists. I did not change anything in the vendor folder.

Any ideas? Thanks in advance for your help.

Zorji

TL;DR You'll just need to generate your proxy classes manually

vendor/bin/doctrine orm:generate-proxies

Doctrine uses Proxies to connect the to database. Proxies are generated from the the Entity classes.

In development mode, it generates a Proxies on every request because you could make changes to Entity classes.

In production mode, it does not generate Proxies every time. For performance reason, it assumes the Proxies exist and include them directly.

There are a few mode for Proxies generation:

  1. ALWAYS - It alwayes generates Proxies, this is the default setting for development mode
  2. NEVER - It never generates Proxies, this is the default setting for production mode
  3. ON_DEMAND - It only generates the Proxies if the Proxy files do not exist. The drawback of this option is that it has to call file_exists() every time which could potentially cause a performance issue.

Now the command

vendor/bin/doctrine orm:generate-proxies

generates Proxy classes to /tmp. I would say this might still cause trouble because other applications on your server might delete these files unexpectedlly. One option is you can change your /tmp directory access permission to 1777

sudo chmod 1777 /tmp

The stricky bit '1' in front of 777 means that, although everyone can read/write to the /tmp directory, but you can only operate on your own files. i.e. You can't remove files created by other users.

For further reading, please have a look at http://docs.doctrine-project.org/en/latest/reference/advanced-configuration.html#auto-generating-proxy-classes-optional

You can also set the Proxies directory to somewhere else so no other applications can modify them. http://docs.doctrine-project.org/en/latest/reference/advanced-configuration.html#autoloading-proxies

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Detached entity error in Doctrine

From Dev

Symfony - doctrine PreUpdateEventArgs error

From Dev

Doctrine migration and fixtures error

From Dev

Doctrine cache unrecognized options error

From Dev

Doctrine Annotations Exception - Strange Error

From Dev

symfony doctrine getArrayResult error 500

From Dev

Symfony 2 Doctrine MS SQL Error

From Dev

Error handling in Doctrine DBAL with comparison to PHP PDO

From Dev

Doctrine "A new entity was found through the relationship" error

From Dev

Error running doctrine:fixtures:load in heroku

From Dev

PostgreSQL, Doctrine SQL syntax error; MySQL works

From Dev

Symfony error while doctrine:database:create

From Dev

Doctrine ManyToMany on Same Entity Duplicate Entry Error

From Dev

Doctrine ORM Error: A Foreign Key Constraint Fails

From Dev

Doctrine @InheritanceType("JOINED") error use statement

From Dev

Doctrine 2 paginator with exotic join throws error

From Dev

Integrating Doctrine in CodeIgniter 3 - entity error

From Dev

Doctrine schema update Error in prod environnement

From Dev

Catch db error with Doctrine\DBAL\Exception

From Dev

Doctrine 2, error inserting in table with foreign key

From Dev

Doctrine ORM Error: A Foreign Key Constraint Fails

From Dev

SymfonyCMF RoutingBundle Doctrine PHPCR configuration error

From Dev

Doctrine ManyToMany on Same Entity Duplicate Entry Error

From Dev

symfony2 & doctrine orderBy/DQL error

From Dev

Error while inserting into db using doctrine ORM

From Dev

Doctrine ArrayCollection with one-to-many throws an error

From Dev

Fatal error: Uncaught Doctrine\ORM\Query\QueryException

From Dev

symfony doctrine validate entity relations error

From Dev

error : php bin/console doctrine:database:create

From Dev

Doctrine - not In

Related Related

  1. 1

    Detached entity error in Doctrine

  2. 2

    Symfony - doctrine PreUpdateEventArgs error

  3. 3

    Doctrine migration and fixtures error

  4. 4

    Doctrine cache unrecognized options error

  5. 5

    Doctrine Annotations Exception - Strange Error

  6. 6

    symfony doctrine getArrayResult error 500

  7. 7

    Symfony 2 Doctrine MS SQL Error

  8. 8

    Error handling in Doctrine DBAL with comparison to PHP PDO

  9. 9

    Doctrine "A new entity was found through the relationship" error

  10. 10

    Error running doctrine:fixtures:load in heroku

  11. 11

    PostgreSQL, Doctrine SQL syntax error; MySQL works

  12. 12

    Symfony error while doctrine:database:create

  13. 13

    Doctrine ManyToMany on Same Entity Duplicate Entry Error

  14. 14

    Doctrine ORM Error: A Foreign Key Constraint Fails

  15. 15

    Doctrine @InheritanceType("JOINED") error use statement

  16. 16

    Doctrine 2 paginator with exotic join throws error

  17. 17

    Integrating Doctrine in CodeIgniter 3 - entity error

  18. 18

    Doctrine schema update Error in prod environnement

  19. 19

    Catch db error with Doctrine\DBAL\Exception

  20. 20

    Doctrine 2, error inserting in table with foreign key

  21. 21

    Doctrine ORM Error: A Foreign Key Constraint Fails

  22. 22

    SymfonyCMF RoutingBundle Doctrine PHPCR configuration error

  23. 23

    Doctrine ManyToMany on Same Entity Duplicate Entry Error

  24. 24

    symfony2 & doctrine orderBy/DQL error

  25. 25

    Error while inserting into db using doctrine ORM

  26. 26

    Doctrine ArrayCollection with one-to-many throws an error

  27. 27

    Fatal error: Uncaught Doctrine\ORM\Query\QueryException

  28. 28

    symfony doctrine validate entity relations error

  29. 29

    error : php bin/console doctrine:database:create

  30. 30

    Doctrine - not In

HotTag

Archive