定制 darkterminal/turso-http-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

darkterminal/turso-http-laravel

最新稳定版本:1.0.1

Composer 安装命令:

composer require darkterminal/turso-http-laravel

包简介

A Turso HTTP SDK for Laravel

README 文档

README

Turso + Laravel

Turso + Laravel

SQLite for Production. Powered by libSQL.

Turso · Quickstart · Examples · Docs · Discord · Blog & Tutorials

A LibSQL HTTP for Laravel

Shows a black logo in light color mode and a white one in dark color mode.

Requirement

Installation

You can install the package via composer:

composer require darkterminal/turso-http-laravel

Then register the service provider at bootstrap/providers.php array:

return [
    App\Providers\AppServiceProvider::class,
    Turso\Http\Laravel\LibSQLHttpServiceProvider::class, // Here
];

Database Configuration

DB_CONNECTION=libsql
DB_DATABASE=<your-turso-database-url>
DB_AUTH_TOKEN=<your-turso-database-auth-token>

Database Configuration

Add this configuration at config/database.php inside the connections array:

'libsql' => [
    'driver' => 'libsql',
    'url' => env('DB_DATABASE', ''),
    'authToken' => env('DB_AUTH_TOKEN', ''),
    'database' => null,
    'prefix' => '',
],

Copy and Paste and do not change it! Or try to change it and will broke your app or give you malfunction.

Usage

For database operation usage, everything have same interface like usual when you using Illuminate\Support\Facades\DB in your database model. But remember, this is LibSQL they have sync method that can be used when you connect with Remote Replica Connection (Embedded Replica).

use Illuminate\Support\Facades\DB;

// Create
DB::table('users')->insert([
    'name' => 'Budi Dalton',
    'email' => 'budi.dalton@duck.com'
]);

// Read
DB::table('users')->get();
DB::table('users')->where('id', 2)->first();
DB::table('users')->orderBy('id', 'DESC')->limit(2)->get();

// Update
DB::table('users')->where('id', 2)->update(['name' => 'Doni Mandala']);

// Delete
DB::table('users')->where('id', 2)->delete();

// Transaction
try {
    DB::beginTransaction();

    $updated = DB::table('users')->where('id', 9)->update(['name' => 'Doni Kumala']);

    if ($updated) {
        echo "It's updated";
        DB::commit();
    } else {
        echo "Not updated";
        DB::rollBack();
    }

    $data = DB::table('users')->orderBy('id', 'DESC')->limit(2)->get();
    dump($data);
} catch (\Exception $e) {
    DB::rollBack();
    echo "An error occurred: " . $e->getMessage();
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固