草庐IT

php - 学说 2.0 Bootstrap ?

coder 2024-05-01 原文

好的,所以我在文件夹层次结构中得到了 Doctrine.php 文件,如下所示:

\
  includes\
    Setup.php
    Doctrine\
      Common\
      DBAL\
      ORM\
      Symfony\
      Doctrine.php

My setup.php has the following:

$rootPath = $_SERVER['DOCUMENT_ROOT'];
$includePath = getcwd() . "\includes";
ini_set('include_path', '.'.PATH_SEPARATOR.$rootPath.PATH_SEPARATOR.$includePath);

require_once 'includes\Doctrine\Doctrine.php';

我的 Doctrine.php 是:

<?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
 * <http://www.doctrine-project.org>.
 */

require_once 'Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();

$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
$classLoader->register();

$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';

$helperSet = null;
if (file_exists($configFile)) {
    if ( ! is_readable($configFile)) {
        trigger_error(
            'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
        );
    }

    require $configFile;

    foreach ($GLOBALS as $helperSetCandidate) {
        if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
            $helperSet = $helperSetCandidate;
            break;
        }
    }
}

$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet();

\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);

现在,当我从 hello world 页面包含我的 setup.php 时,我收到以下警告:

Notice: Undefined index: argv in C:\xampp\htdocs\SpaceWars\includes\Doctrine\Symfony\Component\Console\Input\ArgvInput.php on line 53

Warning: array_shift() expects parameter 1 to be array, null given in C:\xampp\htdocs\SpaceWars\includes\Doctrine\Symfony\Component\Console\Input\ArgvInput.php on line 57

任何人都可以指导我做错了什么吗?我试着用谷歌搜索警告,但似乎找不到任何东西。

最佳答案

您拥有的 doctrine 文件用于从命令行运行 Doctrine 工具。您需要的是类似于此的内容:

    use Doctrine\Common\ClassLoader,
        Doctrine\ORM\Configuration,
        Doctrine\ORM\EntityManager,
        Doctrine\DBAL\Types\Type,
        Doctrine\Common\Cache\ArrayCache,
        Doctrine\DBAL\Logging\EchoSqlLogger;


    // include the class loader directly
    require_once __DIR__ . '/Common/ClassLoader.php';

    $doctrineClassLoader = new ClassLoader('Doctrine', __DIR__ . '/../');
    $doctrineClassLoader->register();

    // Set up caches
    $config = new Configuration;
    $cache = new ArrayCache;
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);

    // Metadata Driver
    $driverImpl = $config->newDefaultAnnotationDriver(array('/path/to/entities'));
    $config->setMetadataDriverImpl($driverImpl);

    // Proxy configuration
    $config->setProxyDir(DB_PROXY_DIR);
    $config->setProxyNamespace(DB_PROXY_NAMESPACE);
    $config->setAutoGenerateProxyClasses(DB_PROXY_GEN);

    // Database connection information
    $connectionOptions = array(
        'driver' => 'pdo_mysql',
        'user' => DB_USER,
        'password' => DB_PASS,
        'host' => DB_HOST,
        'dbname' => DB_NAME,
        'port' => DB_PORT
    );

    // Create EntityManager
    $em = EntityManager::create($connectionOptions, $config);

$em 是您用来保存和检索实体的实体管理器。这来自此处的文档:http://www.doctrine-project.org/docs/orm/2.0/en/reference/configuration.html#obtaining-an-entitymanager

更新 在文件顶部添加了 use 语句。这些是必需的,以便在您使用这些类时不需要完整的命名空间。

关于php - 学说 2.0 Bootstrap ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5444459/

有关php - 学说 2.0 Bootstrap ?的更多相关文章

  1. ruby - 将 Bootstrap Less 添加到 Sinatra - 2

    我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它

  2. ruby-on-rails - 如何在 Ruby on Rails 中实现由 JSF 2.0 (Primefaces) 驱动的 UI 魔法 - 2

    按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭10年前。问题1)我想知道ruby​​onrails是否有功能类似于primefaces的gem。我问的原因是如果您使用primefaces(http://www.primefaces.org/showcase-labs/ui/home.jsf),开发人员无需担心javascript或jquery的东西。据我所知,JSF是一个规范,基于规范的各种可用实现,prim

  3. ruby - Jekyll 2.0 中的 SCSS 生成错误 - 2

    我的项目布局如下:-Project-css-import.scss-_sass/main.scssimport.scss的内容是:------@import"main.scss";我期望发生的是将main.scss导入到import.scss中,然后,import.scss将在生成的_site/目录中编译为import.css。相反,我收到以下错误Conversionerror:Therewasanerrorconverting'css/import.scss'.jekyll2.0.3|Error:InvalidCSSafter"-":expectednumberorfunction,

  4. css - Rails 4.1 和 Bootstrap 3 字形图标不工作 - 2

    我正在尝试消除使用Bootstrap3的Rails4元素中的glyphicon错误。我没有使用任何Bootstrapgem将其添加到Assets管道中。我手动将bootstrap.css和bootstrap.js添加到各自的app/assets目录下,分别添加到application.css和application.js什么的我现在在网络浏览器的控制台中看到以下内容:GEThttp://localhost:3000/fonts/glyphicons-halflings-regular.woff404(NotFound)localhost/:1GEThttp://localhost:30

  5. ruby-on-rails - 这个 C 和 PHP 程序员如何学习 Ruby 和 Rails? - 2

    按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我来自C、php和bash背景,很容易学习,因为它们都有相同的C结构,我可以将其与我已经知道的联系起来。然后2年前我学了Python并且学得很好,Python对我来说比Ruby更容易学。然后从去年开始,我一直在尝试学习Ruby,然后是Rails,我承认,直到现在我还是学不会,讽刺的是那些打着简单易学的烙印,但是对于我这样一个老练的程序员来说,我只是无法将它

  6. ruby - 在 Amazon OpsWorks 上使用 Ruby 2.0 - 2

    我想在AmazonOpsWorks上使用Ruby2.0,所以我正在尝试以下操作:选择自定义Recipe并将它们设置到我的forkhttps://github.com/aws/opsworks-cookbooks在此处更新所有版本号https://github.com/aws/opsworks-cookbooks/blob/master/ruby/attributes/ruby.rb到2.0值。虽然这似乎没有任何效果。自定义说明书是否会覆盖其内置的说明书?OpsWorks是否使用Recipe中的Ruby配方来进行基本的Ruby设置?同样的问题也适用于Nginx-我可以通过更改Recipe

  7. ruby-on-rails - Ruby 1.9.3 -> 2.0 别名方法和扩展 - 2

    我正在尝试将Ruby1.9.3应用程序升级到2.0,除了一个小问题外,一切似乎都很顺利。我写了一个模块,我将其包含在我的模型中以覆盖activerecorddestroy。它将现有的destroy方法别名为destroy!,然后覆盖destroy以更改记录上的deleted_at时间戳。仅当我升级到ruby​​2.0时,destroy!不再破坏记录,但其行为就像我的新覆盖方法一样。知道为什么会这样吗?下面是更相关的代码部分。完整要点here.defself.included(base)base.class_evaldoalias_method:destroy!,:destroyalia

  8. 来自哈希的ruby 2.0命名参数 - 2

    如果我在ruby​​中有一个接受命名参数的方法...defsmoosh(first:nil,second:nil)first+secondend如果键匹配,将散列传递给该方法的最简单方法是什么:params={first:'peanut',second:'butter'}smoosh(params)以上会产生参数错误。更新:这似乎是Sinatra参数工作方式的问题。当我这样做时:get'a_sinatra_route'dohash=params.clonehash.symbolize_keys!smoosh(hash)end它工作正常。仅自行传递参数时,它不起作用。(即使您可以使用符号

  9. ruby 2.0 未定义方法 ObjectSpace.trace_object_allocations - 2

    在ruby​​2.0.0/247或head上试过这个:require'objspace'ObjectSpace.trace_object_allocations->undefinedmethod`trace_object_allocations'forObjectSpace:Module文档说它应该可以工作http://www.ruby-doc.org/stdlib-2.0/libdoc/objspace/rdoc/ObjectSpace.html知道我错过了什么吗? 最佳答案 对于更高的ruby​​版本,您仍然可能会遇到如下错误:

  10. ruby-on-rails - Ruby on Rails : 4. 2.0 rails 和 bin/rails 的区别 - 2

    所以从Rails4.1.x开始,似乎有一种推荐的方法是在应用程序文件夹下使用rails。而不是传统的:railsserverRails官方指南推荐使用bin/railsserver看起来bin/rails正在引用带有附加内容的rails。与rails相比,使用bin/rails的额外好处是什么?第二个问题是——我习惯于使用railsserver、railsconsole等,而不是bin/railsserver、bin/railsconsole。如果不使用bin/rails,我会丢失任何东西吗(比如误加载一些库等)?谢谢。 最佳答案

随机推荐