0

Not able to generate a table from entity (PatMon2.php) using doctrine ORM in its own MVC application.

Application structure is :

/public
/src
..../core   with COntroller, View, Router, Request  and App.php
..../monBundle/Entity/PatMon2.php
....bootstrap.php
/vendor
compose.json

and some other folders and files.

I am not able to generate a table from PatMon2.php entity, and I am getting messages from a different project ( www\Plan2ow instead of www\patmon2). When I created a project, I have copied it and changed namespaces. I also deleted the vendor folder and composer.lock and reinstalled doctrine with other bundles. I checked that old namespace does not exist in the new project using the search tool, which could not find word "Plan2own" in the new project. Despite this, I am not able to generate tables for the new project, and I am getting error messages containing old project namespace "Plan2own".

If I use URL: http://patmon2/index.php/home I can see that I can include /src/bootsrap.php file and /vendor/composer/autoload_real.php. But if I run doctrine:orm on the command line, it complains that it can not include vendor directory.

index.php

<?php
print_r("C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2\public\index.php");
require '../src/bootstrap.php'; //which requires autoload.php

bootstrap.php

<?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
echo( "<br> in bootstrap INC_ROOT = ".INC_ROOT );
require_once '../vendor/autoload.php';
<...>

vendor/autoload.php

<?php 
<...>
        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
        if ($useStaticLoader) {
            require_once __DIR__ . '/autoload_static.php';
            print_r("<br>uses static loader");
            call_user_func(\Composer\Autoload\ComposerStaticInit87d6e473c75d808eefba33ccc9231657::getInitializer($loader));
        }

output in http://patmon2/index.php/home

C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2\public\index.php
in bootstrap INC_ROOT = C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2
uses static loader

Command line error: c:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2>vendor\bin\doctrine orm:schema-tool:update --force --dump-sql

or c:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2>php vendor\doctrine\orm\bin\doctrine

    uses static loader <br> in bootstrap<br> in bootstrap INC_ROOT = C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2PHP 
Warning:  require_once(../vendor/autoload.php): failed to open stream: No such file or directory 
in C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2\src\bootstrap.php on line 69
    PHP Fatal error:  require_once(): Failed opening required '../vendor/autoload.php' 
(include_path='C:\Bitnami\wampstack-5.6.20-0\php\PEAR;C:\Bitnami\wampstack-5.6.20-0\frameworks\smarty\libs;C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\Plan2own\vendor;C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2\vendor') 
in C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2\src\bootstrap.php on line 69

If i use >php vendor\bin\doctrine i am getting file content output:

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../doctrine/orm/bin" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m "$dir");
        fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/doctrine" "$@"

But if i use c:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2>php vendor\doctrine\orm\bin\doctrine i am getting the error above, which complains that can not include '../vendor/autoload.php'. If i make changes to this path, website is not working. ** ############################################################## ** This is the old versin of the question. I made changes which i did not remember in indexp.php, bootstrap.php files. Also included ...patmon2/vendor directory to php.ini file

Command: c:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2> vendor\bin\doctrine orm:schema-tool:update --force --dump-sql

Gives this output:
 <br> index.php  vendorDir  = **string(64) "C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\Plan2own\vendor"
**<br> index.php  baseDir  = **string(57) "C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\Plan2own"
**<br> index.php  vendorDir  = **string(64) "C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\Plan2own\vendor"
**<br> index.php  baseDir  = **string(57) "C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\Plan2own"
**No Metadata Classes to process.

I have made "Plan2own" search through all the folder, and this string was not found. I am on "www\patmon2" with the command line. Why I am getting logs from different namespace? ANd how to tell to doctrine ORM, where are entity files, which I want to convert to tables?

My composer.json

   "autoload": {
        "psr-4": {
            "core\\" : "/src/core/",
            "src\\monBundle\\Entity\\" : "/src/monBundle/Entity/",
            "src\\monBundle\\Controller\\" : "/src/monBundle/Controller/",
            "src\\monBundle\\JsonData\\" : "/src/monBundle/JsonData/",
            "src\\monBundle\\cache\\" : "/src/monBundle/cache/",
            "src\\monBundle\\resources\\" : "/src/monBundle/resources/"
        },
        "classmap": [
            "src/core/App.php",
            "src/core/View.php",
            "src/core/Controller.php"
        ]
    },    

    "require": {
        "doctrine/orm": "^2.5",
        "symfony/console": "~2.5",
        "twig/twig": "^1.24",
        "filp/whoops": "^2.1"
    }  

1 Answer 1

0

Finally, the reason was in wrong include path. When i finish the project, i will upload it to github.

in short C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\www\patmon2\src\bootstrap.php must contain line require_once __DIR__.'/../vendor/autoload.php'; (not require_once '../vendor/autoload.php';)

On windows I should use command : php vendor\doctrine\orm\bin\doctrine (not vendor\bin\doctrine, or php vendor\bin\doctrine).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.