轻量级的PHP数据库框架, 提高开发效率
medoo扩展官网:https://medoo.lvtao.net/1.2/doc.collaboration.php
安装
ubuntu@VM-4-13-ubuntu:/www/wwwroot/laravel7.yshuq.com/laravel7$ sudo composer require catfan/Medoo
./composer.json has been updated
Running composer update catfan/medoo
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking catfan/medoo (v2.1.10)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Downloading catfan/medoo (v2.1.10)
- Installing catfan/medoo (v2.1.10): Extracting archive
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
68 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Found 5 security vulnerability advisories affecting 2 packages.
Run "composer audit" for a full list of advisories.
Using version ^2.1 for catfan/medoo
ubuntu@VM-4-13-ubuntu:/www/wwwroot/laravel7.yshuq.com/laravel7$
使用
在bootstrap/app.php中注册。引入
use Illuminate\Support\Facades\Config;
use Medoo\Medoo;
// Register as database
$app->singleton('medoo', function () {
$config = Config::get('database.connections.mysql');
return new Medoo([
'database_type' => $config['driver'],
'database_name' => $config['database'],
]); });
'server'
'charset'
'port'
'prefix'
'username'
'password'
=> $config['host'],
=> $config['charset'],
=> $config['port'],
=> $config['prefix'],
=> $config['username'],
=> $config['password'],
# 在 route/web.php中测试 Route::get('/', function () {
$data = app('medoo')->select('account', ['id', 'name']);
return json_encode($data);
});