在我的composer.json文件中,我将"kigkonsult/icalcreator": "v2.23.7"
添加到了所需的列表中,在完成安装后,我看到vendor
目录下存在该目录。我无法弄清楚如何在这个项目的PHP文件中“使用”它。
如果我没有使用作曲家,我只需要该区域的icalcreator.php文件。当我通过作曲家包含它时,正确的语法是什么?
答案 0 :(得分:0)
安装软件包后,您需要在项目的某个位置添加composer autoloader。
final int BUFFER_SIZE = 4096;
String fileURL = "https://twc.centercode.com/files/report.aspx/PLS Tracker.csv?t=GetElementFullCSV&r=0668821a036046ef9fde587c609e2c8f&e=47437d179bce477f936dcfdc470bf378";
String fileName = "EFTReportTest.csv";
String saveDir = "D:\\";
URL url = new URL(fileURL);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
int responseCode = httpConn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream inputStream = httpConn.getInputStream();
String saveFilePath = saveDir + "" + fileName;
FileOutputStream outputStream = new FileOutputStream(saveFilePath);
int bytesRead = -1;
byte[] buffer = new byte[BUFFER_SIZE];
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
inputStream.close();
System.out.println("File downloaded");
}
else{
System.out.println("No file to download. Server replied HTTP code: " + responseCode);
}
httpConn.disconnect();
通常作曲家使用Jackson
,但看起来这个包没有。它只是将它自己的自动加载器添加到作曲家中,所以只需包含Composer加载器即可。
添加自动加载器后,您可以根据需要使用该软件包。 Composer将自动注册包自定义自动加载器,PHP将使用它来加载相应的文件。