For example, if I want to remove composer from fuelphp... is there any easy way to remove composer? I mean I ask to use fuelphp (or some framework else) without composer.

有帮助吗?

解决方案 2

No, there is no "simple" way.

To do what Composer does, you'd need to have:

  1. Download all the libraries in the correct version that are directly included.
  2. Also download all libraries that are required by any library in step 1.
  3. Repeat downloading new libraries in step 2 unless you do not find any new, i.e. you completely downloaded all these.
  4. Then create an autoloader for every downloaded library depending on what every configuration for every library said has to be done, i.e. either register a PSR-0 (or PSR-4 if some libs like to live on the edge), or parse the whole source tree for occurrences of classes, interfaces and traits and create an array listing every such class name and the containing file name.
  5. Last but not least find a way to place everything downloaded and created where the regular Composer results would be expected.

Doing this manually is not impossible, but it is ridiculous to do so.

While I do admit that Composer makes it a little bit harder for the uninformed hobbyist programmer to fiddle with his home-brewn scripts when trying to download a new library because he now has to get to know Composer, in the end it makes the lives of everyone much easier - the time invested into getting to know Composer is well invested. Composer will not go away soon. In fact, every other language has something like Composer for a very long time, and nobody complains or tries to remove these dependency managers there.

其他提示

Since composer is part of the framework. You "Do" need it. Period. Otherwise you have to follow @Sven's advice.

Having said that, you often only have a need for composer on your development platform, since that is where you'll want to pull the new code or updates in.

It's perfectly fine to deploy your application (to a staging or production environment) without composer, and without the .git folders. You would not want to have updates pulled in in those environments anyway, all code on these platforms should be under your version control.

FuelPHP from version 1.7+ (I think) requires composer, you would have to modify the autoloader to prevent it from trying to use composer's autoloader. This is not advisable as it means it becomes harder to keep up to date with maintenance releases.

Unfortunately for you composer is rather widespread and so is something that you will have to use if you continue working with frameworks. Fuel ships with a version of the composer.phar so you don't even have to go to the bother of downloading/installing it on your system.

If there is no dependencies, you can always simply do something like :

set_include_path(dirname(__FILE__).'/framework_XYZ');
spl_autoload_extensions(".php");
spl_autoload_register();

without forgetting to change the "framework_XYZ" by the directory where the core/system classes are hiding... ;)

J.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top