Trên GitHub, ziadoz/silex-capsule đã đạt 15 sao, nhóm Backend, ngôn ngữ PHP. A Laravel Eloquent ORM/Capsule service provider for Silex
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
For more information about the available options you should refer to the Capsule documentation.
Once you've registered the service provider a Capsule object will be created and Eloquent booted up before any of your route controllers are called. If you're interested in the technical aspects, Capsule is registered as before middleware with Silex using Application::EARLY_EVENT, so it'll only ever be made available once your application is run and before anything else happens.
If you need Capsule and Eloquent to be booted up before your application is run ($app->run()), for example in a Symfony Console command, you just need to access its array element within the dependency injection container:
$app['capsule'];
Capsule will be made available globally by default, allowing you to write queries directly in your controllers should you wish:
use Illuminate\Database\Capsule\Manager as Capsule;
$app->get('/book/{id}', function(Application $app, $id) {
$book = Capsule::table('books')->where('id', $id)->get();
return $app->json($book);
});
If you don't want Capsule to be booted then set the capsule.global setting to false. If you don't plan to use Eloquent to build models then you can also prevent it from being booted by setting capsule.eloquent to false.
Creating Eloquent models is identical to how you would create them in Laravel:
use Illuminate\Database\Eloquent\Model;
class Book extends Model
{
protected $table = 'books';
protected $fillable = [
'title',
'author',
];
protected $casts = [
'title' => 'string',
'author' => 'string',
];
// The rest of your model code...
}
Then you can use it, and all of its features, in your controllers just like you would in Laravel:
There are some basic tests to ensure that the Capsule object is correctly registered with Silex. You can run them using PHPUnit, and you'll also need SQLite as the tests use a simple in-memory database.
If you make a pull request please ensure you add the accompanying tests.
ziadoz/silex-capsule thuộc nhóm Backend trên TopGit, cùng 5 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về ziadoz/silex-capsule ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/ziadoz/silex-capsule là nguồn chính thức.
Vì sao ziadoz/silex-capsule được xếp vào nhóm Backend?
TopGit xếp ziadoz/silex-capsule vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "capsule", "eloquent", "laravel"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
ziadoz/silex-capsule có bao nhiêu sao?
ziadoz/silex-capsule có 15 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/ziadoz/silex-capsule. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
ziadoz/silex-capsule có những chủ đề gì?
GitHub topics của ziadoz/silex-capsule: "capsule", "eloquent", "laravel", "php", "silex". TopGit xếp repo vào nhóm Backend.
ziadoz/silex-capsule còn đang phát triển không?
Commit gần nhất trên ziadoz/silex-capsule là 7.1 năm trước (theo timestamp GitHub). Repo có 7 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
ziadoz/silex-capsule viết bằng ngôn ngữ gì?
ziadoz/silex-capsule chủ yếu viết bằng PHP. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
silex-capsule có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về silex-capsule.