Hướng dẫn tích hợp Ramsey Collection vào để sử dụng với PHP (ok)
Bạn có thể dử dụng kết hợp với illuminate/database hoặc laravel/tinker ... có thể được bởi vì bản thân mình ramsey/collection nó không sử dụng được 😒😒
Mẫu sau không hoạt động được :)
{
"name": "illuminate-example/eloquent",
"description": "Implementation of Database Queries with illuminate and Eloquent",
"type": "project",
"require":
{
"ramsey/collection": "^1.2"
}
}
Mẫu sau hoạt động tốt
{
"name": "illuminate-example/eloquent",
"description": "Implementation of Database Queries with illuminate and Eloquent",
"type": "project",
"require":
{
"illuminate/database": "5.1.8",
"ramsey/collection": "^1.2"
}
}
C:\xampp\htdocs\test\index.php
<?php
require 'vendor/autoload.php';
$average = collect([
['foo' => 10],
['foo' => 10],
['foo' => 20],
['foo' => 40],
])->avg('foo');
dd($average);
?>
Kết quả:

Hoặc
{
"name": "illuminate-example/eloquent",
"description": "Implementation of Database Queries with illuminate and Eloquent",
"type": "project",
"require":
{
"laravel/tinker": "^2.5",
"ramsey/collection": "^1.2"
}
}
Thông thường nó sử dụng dạng sau :)
{
"name": "illuminate-example/eloquent",
"description": "Implementation of Database Queries with illuminate and Eloquent",
"type": "project",
"require":
{
"illuminate/database": "^2.5",
"ramsey/collection": "^1.2"
},
"autoload":
{
"psr-4":
{
"Controllers\\": "app/controllers/",
"Models\\": "app/models/"
}
}
}
PreviousUse Eloquent Illuminate in PHP Without Laravel P2NextPhân tích luồng Request trong Laravel (ok)
Last updated
Was this helpful?