syren7/owncloud-api-bundle
Composer 安装命令:
composer require syren7/owncloud-api-bundle
包简介
This Bundle allows you to manage owncloud users throug provisioning api and managing files through sabre dav
README 文档
README
This ownCloud API Bundle allows you to access user, groups, shares, files and calendars of your ownCloud. At the moment there are only party of the full features available but I will try to implement every feature. If there are any questions, problems or if you would try to participate at the project leave me a comment or send an email
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require syren7/owncloud-api-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Syren7\OwncloudApiBundle\Syren7OwncloudApiBundle(), ); // ... } // ... }
Step 3: Configure the Bundle
You will need now to configure your parameters for using this bundle.
IMPORTANT: Make sure that you're using https for encryption because passwords will be transmitted in plaintext
// app/config/config.yml // YOU SHOULD NOT SET SENSITIVE DATA HERE! syren7_owncloud: host: '%owncloud_host%' user: '%owncloud_user%' pass: '%owncloud_pass%' folder: '%owncloud_folder%' #NOTE: this setting is optional
// app/config/parameters.yml owncloud_host: 'UrlToYouOwncloudServer' #e.g. https://cloud.yourhost.com/ or https://yourhost.com/owncloud/ owncloud_user: 'YourOwncloudUsername' #if you want to access user specific functions (like adding and removeing), make sure your owncloud user has enough rights owncloud_pass: 'YourOwncloudPassword' owncloud_folder: 'RootFolderForStoringFiles' # You can add here some folder where you want to store your files. Leave empty if you want to user the users root directory
Take care about the owncloud_folder parameter. If you leave it empty, the bundle always uses the home (or root) directory of the user given in owncloud_user.
If you would like to store the data in a subfolder of the user, please set it in owncloud_folder relative to the users home directory!
e.g. you have folder named files of bob in bobs home directory and you would like to store all files created by the bundle inside this directory, set owncloud_folder to owncloud_folder: "files of bob/".
As mentioned in the example Filesystem example:
If you scan the directory with getDirectoryContents() with no parameters, the bundle will now scan files of bob/ instead of bob's home directory.
Step 4: Using the Bundle
You have now three services for contacting an owncloud server. syren7_owncloud.filesystem for accessing the webDav service and syren7_owncloud.user for managing users, groups and subadmins on your owncloud instance.
// in some controller file you can do the following $this->get('syren7_owncloud.filesystem'); //using filesystem tools on owncloud $this->get('syren7_owncloud.user'); //managing users and groups $this->get('syren7_owncloud.calendar'); //reading calendars and events
Debbuging
For debugging purposes you could call the getLastRequest() Method from the service. It will return the response from your OwnCloud server. So you can see which type of error was thrown corresponding to the docs on OwnCloud Api.
#Example of an response from server
Examples
You can see other examples and further documentation within the docs/ folder
Filesystem example
If you want to work with this api without symfony you can do this simply with the following example:
//Basic example for the filesystem api //edit the following line, if you have your vendors not installed to vendor/ Folder require_once 'vendor/autoload.php'; //create a new object with your owncloud credentials $fs = new \Syren7\OwncloudApiBundle\Service\OwncloudFilesystem('YourHostNameHere', 'YourOcUserName', 'YourOcPassword', 'LeaveBlankIfYouWantToWriteIntoUsersRootDirectory'); //do your operations as you would do in symfony //List all files and directories (optional give a subdirectory as parameter) $fs->getDirectoryContents('Optional:YourPathToADirectory'); //returns a file handle from Oc. Filname as parameter $file = $fs->getFile('Path/To/File.txt'); //write file to local filesystem file_put_contents('Path/To/New/Local/File.txt', $file->read()); //create a directory $fs->createDirectory('Path/To/New/Directory/On/Your/Oc'); //remove a directory $fs->removeDirectory('Path/To/Remove/Directory/On/Your/Oc'); //uploads a file to your oc $fs->createFile('Local/Path/To/File.txt', 'Optional: Remote/Path/To/File'); //removes a file from your oc $fs->removeFile($path=''); //rename a file on your cloud ($file is the file returned by $fs->getFile()) $fs->renameFile(File $file, 'newFileName.txt'); //copy a file on your cloud ($file is the file returned by $fs->getFile()) $fs->copyFile(File $file, 'newFileName.txt');
Development
This bundle is still under development and if you would like to participate, let me know! You can also write an email
Donations
This is a completely free project and you can use it wherever you want. If you like this bundle and would like to donate some "coffee" feel free to do that on PayPal
syren7/owncloud-api-bundle 适用场景与选型建议
syren7/owncloud-api-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 966 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 01 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「dav」 「owncloud」 「ocs」 「sabre-dav」 「owncloudapi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 syren7/owncloud-api-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 syren7/owncloud-api-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 syren7/owncloud-api-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
ownCloud Coding Standard
Sabre DAV server adapter for Laravel.
CardDAV client library to discover and synchronize with CardDAV servers
CardDAV adapter for connecting to CardDAV-enabled addressbooks
Behat tools
Sync files from various sources to neos assets.
统计信息
- 总下载量: 966
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL2
- 更新时间: 2016-01-09