jeandormehl / laracache
InterSystems Caché 提供商 (ODBC) 用于 Laravel
Requires
- php: ^8.0|^8.1
- illuminate/database: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- mockery/mockery: ^1.4
- nunomaduro/collision: ^6.3
- orchestra/testbench: ^7.7
- pestphp/pest: ^1.22
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-19 23:09:01 UTC
README
Laracaché
Laracaché 是一个 InterSystems Caché 数据库驱动程序包,用于 Laravel。Laracaché 是 Illuminate/Database 的扩展,使用 php-odbc 扩展与 Caché 进行通信。此包与 Eloquent 协作良好。
快速安装
PHP >= 8 和 Laravel >= 8
composer require jeandormehl/laracache
环境变量
修改您的 .env 文件,使其类似于以下内容。Windows 用户只需要设置 DB_CONNECTION
和 DB_WIN_DSN
变量。Unix 用户应设置以下所有变量
DB_CONNECTION=isc
DB_WIN_DSN=
DB_UNIX_DRIVER=/usr/lib/intersystems/odbc/bin/libcacheodbcur6435.so
DB_HOST=127.0.0.1
DB_PORT=1972
DB_DATABASE=LARAVEL
DB_USERNAME=_SYSTEM
DB_PASSWORD=SYS
配置
通过运行以下 Artisan 命令发布配置文件。
php artisan vendor:publish --tag=isc
这会将配置文件复制到 config/isc.php
。
'isc' => [ 'driver' => 'odbc', 'win_dsn' => env('DB_WIN_DSN', ''), // windows users only 'unix_driver' => env('DB_UNIX_DRIVER', ''), // unix users only 'host' => env('DB_HOST', ''), 'port' => env('DB_PORT', 1972), 'database' => env('DB_DATABASE', ''), // namespace 'username' => env('DB_USERNAME', '_SYSTEM'), 'password' => env('DB_PASSWORD', 'SYS'), 'schema' => env('DB_SCHEMA', 'SQLUser'), // SQLUser is default, avoid changing if possible 'options' => [ \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ, 'processor' => \Laracache\Cache\Query\Processors\Processor::class, 'grammar' => [ 'query' => \Laracache\Cache\Query\Grammars\Grammar::class, 'schema' => \Laracache\Cache\Schema\Grammars\Grammar::class, ], ], ],
Caché 的 ODBC 驱动程序
您需要确保已安装相关的 ODBC 驱动程序。对于 Linux 发行版,我建议使用 unixODBC 驱动程序,特别是 64 位版本的 libcacheodbcur6435.so
。如果您遇到任何问题,请尝试切换到 libcacheodbcur64.so
。
unixODBC
下载、解压并构建 unixODBC 包。此示例使用版本 2.3.7。
# get unixODBC wget -q ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.7.tar.gz # untar the package sudo tar -xzvf unixODBC-2.3.7.tar.gz # navigate to build file path, in this case, ~/unixODBC-2.3.7 cd ~/unixODBC-2.3.7 # build the package - modify prefix, sysconfdir and doc location as needed sudo -s <<EOF ./configure --prefix=/usr --sysconfdir=/etc \ && make \ && make install \ && find doc -name "Makefile*" -delete \ && chmod 644 doc/{lst,ProgrammerManual/Tutorial}/* \ && install -v -m755 -d /usr/share/doc/unixODBC-2.3.7 \ && cp -v -R doc/* /usr/share/doc/unixODBC-2.3.7 EOF
php-odbc
确保已安装 php-odbc 扩展。此示例使用 Apache 和 PHP 7.2。
sudo apt-get -y update
sudo apt-get -y install php-odbc
# restart services
sudo service apache2 restart
sudo service php7.2-fpm restart
InterSystems ODBC 驱动程序
下载、解压并安装。此示例使用 Ubuntu 64 位版本的 2018.1.0.184.0 构建。在此链接中查找可用的驱动程序:InterSystems ODBC 驱动程序
# download drivers wget -q ftp://ftp.intersys.com/pub/cache/odbc/2018/ODBC-2018.1.0.184.0-lnxubuntux64.tar.gz # create a directory to hold drivers and copy tar file to it sudo mkdir -p /usr/lib/intersystems/odbc sudo cp ODBC-2018.1.0.184.0-lnxubuntux64.tar.gz /usr/lib/intersystems/odbc # untar the file and run installer sudo tar -xzvf /usr/lib/intersystems/odbc/ODBC-2018.1.0.184.0-lnxubuntux64.tar.gz sudo /usr/lib/intersystems/odbc/ODBCinstall
/etc/odbc.ini
完成上述步骤后,您应在 /etc 中找到一个名为 odbc.ini 的文件。使用 vi 或 nano 编辑此文件。它应类似于以下内容
[ODBC Data Sources]
cache=cache
[cache]
Driver = /usr/lib/intersystems/odbc/bin/libcacheodbcur6435.so
Description = InterSystems Cache ODBC Connection
Protocol = TCP
Query Timeout = 1
Static Cursors = 0
Authentication Method = 0
注册并创建到游标的符号链接。
# register sudo odbcinst -i -s -f /etc/odbc.ini # create the symlink sudo ln -s /usr/lib/x86_64-linux-gnu/libodbccr.so.2.0.0 /usr/lib/x86_64-linux-gnu/odbc/libodbccr.so
对于 Windows,在管理工具中设置 ODBC 数据源,并在配置文件 isc.php
中设置 win_dns
设置为您的 ODBC 数据源名称。
贡献
您可以使用 VSCODE 远程容器运行此项目。确保您将使用内部 VSCODE 终端(在运行容器内)。
composer install
composer test
composer test:coverage
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。