如何避免在 Laravel 4 中使用 php composer dump-autoload?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17186605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:59:49  来源:igfitidea点击:

How to avoid using php composer dump-autoload with laravel 4?

laravelcomposer-php

提问by ElGato

I have uploaded my project on a web host and I use ftp to edit my code. The problem is that I added models using eloquent for my database and to get it work I have to download my project dans run php composer dump-autoload then re-upload. Otherwise its say class not found ... Doing this all the time is just heavy. Is there any other solution? My webhost does not have ssh or any thing to connect to the server. Neither I can use rsync like stuff. Maybe I should use an other framework than laravel4 to avoid using composer?

我已将我的项目上传到网络主机上,并使用 ftp 来编辑我的代码。问题是我使用 eloquent 为我的数据库添加了模型,为了让它工作,我必须下载我的项目 dans run php composer dump-autoload 然后重新上传。否则它说的类没有找到......一直这样做是很重的。还有其他解决方案吗?我的虚拟主机没有 ssh 或任何连接到服务器的东西。我也不能使用 rsync 之类的东西。也许我应该使用 laravel4 以外的其他框架来避免使用作曲家?

回答by CashIsClay

In your case, you should add your needed autoload directory to the ClassLoader::addDirectories array under /app/start/global.php. Laravel gives multiple ways to accomplish the same thing depending on your personal needs.

在您的情况下,您应该将您需要的自动加载目录添加到 /app/start/global.php 下的 ClassLoader::addDirectories 数组。Laravel 提供了多种方法来完成同一件事,具体取决于您的个人需求。

回答by Rob Gordijn

You can remove or not upload the bootstrap/compiled.php file. I'm not sure if this completely fixes your problem, because I'm not sure if dump-autoload generates multiple files.

您可以删除或不上传 bootstrap/compiled.php 文件。我不确定这是否完全解决了您的问题,因为我不确定 dump-autoload 是否生成多个文件。

[edit]An other approach is to work on your local machine and upload after you are finished.

[编辑]另一种方法是在您的本地机器上工作并在您完成后上传。

回答by Joeri

I'm not sure, sometimes it works, sometimes not...

我不确定,有时有效,有时无效...

But I upload:

但我上传:

  • bootstrap/autoload.php
  • vendor/autoload.php
  • vendor/composer/*
  • 引导程序/自动加载.php
  • 供应商/自动加载.php
  • 供应商/作曲家/*

And I don't have a bootstrap/compiled.php

而且我没有 bootstrap/compiled.php