在PHP Web应用程序中实现完整dependency declaration and isolation的最佳方法是什么?我已经知道了Composer,但这只是声明部分,我认为它还远远不够。我想尽可能多地包括以下内容:PHP扩展(例如mcrypt,imagick,apc),php.ini配置和扩展配置,PECL包,理想情况下甚至是我的Apache配置文件。是否有类似Ruby的bundle exec
用于PHP?
答案 0 :(得分:1)
您可以查看PHP_CompatInfo。
这不会在任何配置文件中报告信息,但它会告诉您需要运行的PHP代码。
答案 1 :(得分:0)
Composer替代Bundler的public class CompareEverything {
public static void sort(List someList, int columnNumber) {
Collections.sort(someList, new EverythingComparator(columnNumber));
}
public static class EverythingComparator implements Comparator<List<?>> {
private int columnNumber;
public EverythingComparator(int columnNumber) {
this.columnNumber = columnNumber;
}
@Override
public int compare(List<?> list1, List<?> list2) {
Object obj1 = list1.get(columnNumber);
Object obj2 = list2.get(columnNumber);
return CompareEverything.compare(obj1, obj2);
}
}
public static int compare(Object obj1, Object obj2) {
int result = 0;
if (obj1 == null) {
result = (obj2 == null) ? 0 : -1;
}
else if (obj2 == null) {
result = 1;
}
else if (obj1 instanceof CharSequence && obj2 instanceof CharSequence) {
// String, StringBuilder, StringBuffer, etc.
result = obj1.toString().compareTo(obj2.toString());
}
else if (obj1 instanceof Number && obj2 instanceof Number) {
Number num1 = (Number)obj1;
Number num2 = (Number)obj2;
// Short, Integer, or Long
if (isIntegral(obj1.getClass()) && isIntegral(obj2.getClass())) {
result = Long.compare(num1.longValue(), num2.longValue());
}
else { // Float, Double, or any mismatched combo
result = Double.compare(num1.doubleValue(), num2.doubleValue());
}
}
// add other types...
else {
// mismatched types - compare as Strings
// or maybe throw a RuntimeException?
result = obj1.toString().compareTo(obj2.toString());
}
return result;
}
private static boolean isIntegral(Class<?> type) {
return Short.class.equals(type) || Integer.class.equals(type) || Long.class.equals(type);
}
}
是bundle exec
。查看文档:{{3}}
答案 2 :(得分:-1)
有一个工具允许通过debian软件包系统基于symfony2分发您的PHP应用程序。见https://github.com/mjollnir/sf2debpkg