我正在做一个有在线音乐流的项目.
我有一个名为Song的对象数组- 该数组Song中的每首歌都有一个来自SoundCloud的URL.
快速枚举每首歌曲,然后调用SoundCloud Resolve API以获取每首歌曲的直接流URL.并将每个直接URL存储到一个数组中并加载到我的播放器.
这看起来非常简单,但#2步骤是异步的,因此每个直接URL都可以存储到错误的数组索引中.我正在考虑使用Insert AtIndex而不是append,所以我在Playground中制作了一个示例代码,因为我的所有想法都使得直接URL的存储保留了它的顺序,但是没有成功.
var myArray = [String?]()
func insertElementAtIndex(element: String?, index: Int) {
if myArray.count == 0 {
for _ in 0...index {
myArray.append("")
}
}
myArray.insert(element, atIndex: index)
}
insertElementAtIndex("HELLO", index: 2)
insertElementAtIndex("WORLD", index: 5)
Run Code Online (Sandbox Code Playgroud)
我的想法是在这个游乐场代码中,它当然会产生错误,最后,我的问题是:使用这个插入atIndex的正确方法是什么?
我不是网络开发人员(我是移动开发人员),因此想弄清楚这一点。
我正在使用这个库:https : //github.com/ktamas77/firebase-php
通过遵循作曲者网站上的文档,我在计算机上安装了“ composer”。
我已经使用以下命令在#1中安装了该库:'php composer.phar require ktamas77 / firebase-php dev-master'
在我的项目中的某个屏幕或php文件中,我要添加以下内容:
$ firebase = new \ Firebase \ FirebaseLib(DEFAULT_URL,DEFAULT_TOKEN);
当我运行或转到该特定屏幕时,会出现如下错误:
消息:找不到类“ Firebase \ FirebaseLib”
我的问题是:为什么?为什么这个freakin php项目找不到FirebaseLib?我可以验证我的项目中是否有这样的文件,因为可以从上面的代码中打开文件。
该文件的路径是这样的:
'/Applications/MAMP/htdocs/xxx-cms/vendor/ktamas77/firebase-php/src/firebaseLib.php'
Run Code Online (Sandbox Code Playgroud)
是否需要在我的php文件顶部添加“ require”?
我尝试添加需求,但添加该对象时出错到该需求。
最后,我什至修改了我的composer.json并添加了“ autoload”,如此处所建议:与Firebase的PHP连接如何工作?
{
"description": "The CodeIgniter framework",
"name": "codeigniter/framework",
"type": "project",
"homepage": "https://codeigniter.com",
"license": "MIT",
"support": {
"forum": "http://forum.codeigniter.com/",
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
"irc": "irc://irc.freenode.net/codeigniter",
"source": "https://github.com/bcit-ci/CodeIgniter"
},
"require": {
"php": ">=5.2.4",
"ktamas77/firebase-php": "dev-master"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x" …Run Code Online (Sandbox Code Playgroud)