1 
PHP Conference 2014 東京 
5分でわかる!ownCloudアドオンの作り方 
株式会社ビーグッド・テクノロジー
髙橋 裕樹(たかはしゆうき) 
東京都八王子生まれ多摩育ち
BeGood Technology 
自己紹介 
1111999988880000年11110000月33331111日生まれ 
uuuukkkkiiiittttiiiiyyyyaaaannnn 
 経歴: システム運用4年・システム開発7年経験 
近頃はownCloudや他OSSを眺める担当 
 あだ名: マギー 
 ownCloudの好きな機能: External Storage 
 その他: PHPより、Java寄り
BeGood Technology 
活動紹介 
Japan ownCloud User Group (JOUG) 
 http://owncloud.jp/forum/ 
ownCloud 日本語サポート 
 http://owncloud.jp/service/our-supports
まずは、ownCloudの概要 
~What is ownCloud~ 
BeGood Technology
BeGood Technology 
What is ownCloud 
Dropboxとかオンラインストレージ 
サービスって、便利だけど、セキュ 
リティとか心配。 
NO IT CONTROL 
・Security 
・Governance 
NO IT CONTROL 
・Storage and Servers 
・User Provisioning
BeGood Technology 
What is ownCloud 
専用の環境に構築すれば 
良いじゃない!
BeGood Technology 
What is ownCloud 
ownCloudは専用の環境に 
オンラインストレージを構築する 
ためのPHPアプリケーション。 
IT MANAGED 
・Storage and Servers 
・User Provisioning 
IT MANAGED 
・Security 
・Governance
BeGood Technology 
What is ownCloud 
実際に作ったのはこの人 
Frankさん 
(Frank Karlitschek)
BeGood Technology 
Why is ownCloud 
1 
オープンソース
無料・商用での利用が可能なデュアルライセンスを採用 
したオープンソースです。 
2 
操作性
ファイルのDragDropやマルチデバイス対応等、DropBox 
と同等の操作が行えます。 
3 
汎用性
クラウド環境や、クローズドな自社サーバー等設置 
環境を選びません。 
4 
拡張性
WebDavやアドオン機構、多数のAPIを搭載しているので、 
PHPの実装で機能を拡張できます。
BeGood Technology 
Why is ownCloud 
1 
オープンソース
無料・商用での利用が可能なデュアルライセンスを採用 
したオープンソースです。 
2 
操作性
ファイルのDragDropやマルチデバイス対応等、DropBox 
と同等の操作が行えます。 
3 
汎用性
クラウド環境や、よりセキュアな自社サーバー等設置 
環境を選びません。 
4 
拡張性
WebDavやアドオン機構、多数のAPIを搭載しているので、 
PHPの実装で機能を拡張できます。
ownCloudアドオンの作り方 
~ How to cook ownCloud app ~ 
BeGood Technology
BeGood Technology 
This Cooks Goal 
何を作るか 
 単純な「Hello World」アプリケー 
ションです 
何を知るか 
 MVC(app framework)を使っ 
たアプリケーションの書き方と、 
配置方法を知る事ができます 
HELLO
mysql CREATE DATABASE owncloud; 
mysql GRANT ALL PRIVILEGES ON owncloud.* 
TO owncloud@127.0.0.1 IDENTIFIED BY 
owncloud; 
BeGood Technology 
Pre-requisites 
LAMP環境構築して、Python3イン 
ストールおいてください。 
以下のSQL叩いておいてください。 
pipから”ocdev”をインストールして 
おいてください。 
githubからソースコードダウンロード 
しておいてください。(tag : v7.0.2) 
PHP5.4 
# sudo pip3 install ocdev
BeGood Technology 
Directory Overview(owncloud core) 
owncloud 
(github.com/owncloud/core.git) 
core・config・l10n・themes・etc.. 
apps 
3rdparty 
(github.com/owncloud/3rdparty.git)
BeGood Technology 
Directory Overview(owncloud core) 
owncloud 
(github.com/owncloud/core.git) 
core・config・l10n・themes・etc.. 
apps 
3rdparty 
(github.com/owncloud/3rdparty.git) 
ここにアプリを実装します 
ここに移動してください。 
# sudo su - 
# cd /var/www/html/owncloud/apps
# ocdev startapp HelloWorld ¥ 
--mail hoge@example.com ¥ 
--author hoge ¥ 
--description My first app ¥ 
--owncloud 7 
# chown –R apache:apache hellowold 
BeGood Technology
BeGood Technology 
Directory Overview(app) 
helloworld appinfo 
css, img, js 
controller 
templates 
tests 
Contains app metadata 
and configuration 
Contains the controllers 
Contains the templates 
(Template and Twig) 
Contains the tests
BeGood Technology 
Activation 1
BeGood Technology 
Activation 2
BeGood Technology 
Activation 3 
出来上がり!!
BeGood Technology 
Hooks 
SSSSeeeeccccttttiiiioooonnnn LLLLiiiisssstttteeeennnn CCCCaaaallllllllbbbbaaaacccckkkk 
UserManager preCreateUser 
postCreateUser 
(string $uid, string $password) 
(¥OC¥User¥User $user) 
preLogin 
postLogin 
(string $user, string $password) 
(¥OC¥User¥User $user) 
logout (¥OC¥User¥User $user) 
Filesystem preWrite 
postWrite 
(¥OCP¥Files¥Node $node) 
preCreate 
postCreate 
(¥OCP¥Files¥Node $node) 
preDelete 
postDelete 
(¥OCP¥Files¥Node $node) 
preCopy、postCopy 
preRename、postRename 
(¥OCP¥Files¥Node $source, 
¥OCP¥Files¥Node $target) 
Filesystem Scanner scanFile、scanFolder (string $absolutePath)
BeGood Technology 
WebDav 
MMMMeeeetttthhhhoooodddd UUUURRRRIIII OOOOppppttttiiiioooonnnn 
PROFIND /remote.php/webdav/Directory 
GET /remote.php/webdav/Path 
PUT /remote.php/webdav/Path 
MOVE /remote.php/webdav/Path Destination:/remote.php/webdav/ 
Path 
COPY /remote.php/webdav/Path Destination:/remote.php/webdav/ 
Path 
PROPPATCH /remote.php/webdav/Path 
MKCOL /remote.php/webdav/Directory 
DELETE /remote.php/webdav/Directory
BeGood Technology 
Etc.. 
SSSSeeeeccccttttiiiioooonnnn DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn 
Classloader The classloader is provided by ownCloud and loads all your 
classes automatically. 
Background Jobs 
(Cron) 
Background/cron jobs are usually registered in the 
appinfo/app.php by using the addRegularTask method 
Logging The logger can be injected from the ServerContainer 
Dependency Injection This class extends Pimple for reusability To use this class, 
extend your own container from this. 
External API The external API inside ownCloud allows third party developers 
to access data provided by ownCloud apps. 
Translation Translation String are shown by editing l10n File To translate 
Theming Themes can be used to customize the look and feel of 
ownCloud.
BeGood Technology 
Try 
Startup 
 https://aws.amazon.com/marketplace/pp/B00F8I7IXG/ 
v7.0.2を選択 
してください 
(申請中。。) 
Sample 
 https://github.com/ukitiyan/helloworld
BeGood Technology 
ご清聴 
ありがとうございました。

5分でわかる!ownCloudアドオンの作り方

  • 1.
    1 PHP Conference2014 東京 5分でわかる!ownCloudアドオンの作り方 株式会社ビーグッド・テクノロジー
  • 2.
    髙橋 裕樹(たかはしゆうき) 東京都八王子生まれ多摩育ち BeGoodTechnology 自己紹介 1111999988880000年11110000月33331111日生まれ uuuukkkkiiiittttiiiiyyyyaaaannnn 経歴: システム運用4年・システム開発7年経験 近頃はownCloudや他OSSを眺める担当 あだ名: マギー ownCloudの好きな機能: External Storage その他: PHPより、Java寄り
  • 3.
    BeGood Technology 活動紹介 Japan ownCloud User Group (JOUG) http://owncloud.jp/forum/ ownCloud 日本語サポート http://owncloud.jp/service/our-supports
  • 4.
    まずは、ownCloudの概要 ~What isownCloud~ BeGood Technology
  • 5.
    BeGood Technology Whatis ownCloud Dropboxとかオンラインストレージ サービスって、便利だけど、セキュ リティとか心配。 NO IT CONTROL ・Security ・Governance NO IT CONTROL ・Storage and Servers ・User Provisioning
  • 6.
    BeGood Technology Whatis ownCloud 専用の環境に構築すれば 良いじゃない!
  • 7.
    BeGood Technology Whatis ownCloud ownCloudは専用の環境に オンラインストレージを構築する ためのPHPアプリケーション。 IT MANAGED ・Storage and Servers ・User Provisioning IT MANAGED ・Security ・Governance
  • 8.
    BeGood Technology Whatis ownCloud 実際に作ったのはこの人 Frankさん (Frank Karlitschek)
  • 9.
    BeGood Technology Whyis ownCloud 1 オープンソース 無料・商用での利用が可能なデュアルライセンスを採用 したオープンソースです。 2 操作性 ファイルのDragDropやマルチデバイス対応等、DropBox と同等の操作が行えます。 3 汎用性 クラウド環境や、クローズドな自社サーバー等設置 環境を選びません。 4 拡張性 WebDavやアドオン機構、多数のAPIを搭載しているので、 PHPの実装で機能を拡張できます。
  • 10.
    BeGood Technology Whyis ownCloud 1 オープンソース 無料・商用での利用が可能なデュアルライセンスを採用 したオープンソースです。 2 操作性 ファイルのDragDropやマルチデバイス対応等、DropBox と同等の操作が行えます。 3 汎用性 クラウド環境や、よりセキュアな自社サーバー等設置 環境を選びません。 4 拡張性 WebDavやアドオン機構、多数のAPIを搭載しているので、 PHPの実装で機能を拡張できます。
  • 11.
    ownCloudアドオンの作り方 ~ Howto cook ownCloud app ~ BeGood Technology
  • 12.
    BeGood Technology ThisCooks Goal 何を作るか 単純な「Hello World」アプリケー ションです 何を知るか MVC(app framework)を使っ たアプリケーションの書き方と、 配置方法を知る事ができます HELLO
  • 13.
    mysql CREATE DATABASEowncloud; mysql GRANT ALL PRIVILEGES ON owncloud.* TO owncloud@127.0.0.1 IDENTIFIED BY owncloud; BeGood Technology Pre-requisites LAMP環境構築して、Python3イン ストールおいてください。 以下のSQL叩いておいてください。 pipから”ocdev”をインストールして おいてください。 githubからソースコードダウンロード しておいてください。(tag : v7.0.2) PHP5.4 # sudo pip3 install ocdev
  • 14.
    BeGood Technology DirectoryOverview(owncloud core) owncloud (github.com/owncloud/core.git) core・config・l10n・themes・etc.. apps 3rdparty (github.com/owncloud/3rdparty.git)
  • 15.
    BeGood Technology DirectoryOverview(owncloud core) owncloud (github.com/owncloud/core.git) core・config・l10n・themes・etc.. apps 3rdparty (github.com/owncloud/3rdparty.git) ここにアプリを実装します ここに移動してください。 # sudo su - # cd /var/www/html/owncloud/apps
  • 16.
    # ocdev startappHelloWorld ¥ --mail hoge@example.com ¥ --author hoge ¥ --description My first app ¥ --owncloud 7 # chown –R apache:apache hellowold BeGood Technology
  • 17.
    BeGood Technology DirectoryOverview(app) helloworld appinfo css, img, js controller templates tests Contains app metadata and configuration Contains the controllers Contains the templates (Template and Twig) Contains the tests
  • 18.
  • 19.
  • 20.
    BeGood Technology Activation3 出来上がり!!
  • 21.
    BeGood Technology Hooks SSSSeeeeccccttttiiiioooonnnn LLLLiiiisssstttteeeennnn CCCCaaaallllllllbbbbaaaacccckkkk UserManager preCreateUser postCreateUser (string $uid, string $password) (¥OC¥User¥User $user) preLogin postLogin (string $user, string $password) (¥OC¥User¥User $user) logout (¥OC¥User¥User $user) Filesystem preWrite postWrite (¥OCP¥Files¥Node $node) preCreate postCreate (¥OCP¥Files¥Node $node) preDelete postDelete (¥OCP¥Files¥Node $node) preCopy、postCopy preRename、postRename (¥OCP¥Files¥Node $source, ¥OCP¥Files¥Node $target) Filesystem Scanner scanFile、scanFolder (string $absolutePath)
  • 22.
    BeGood Technology WebDav MMMMeeeetttthhhhoooodddd UUUURRRRIIII OOOOppppttttiiiioooonnnn PROFIND /remote.php/webdav/Directory GET /remote.php/webdav/Path PUT /remote.php/webdav/Path MOVE /remote.php/webdav/Path Destination:/remote.php/webdav/ Path COPY /remote.php/webdav/Path Destination:/remote.php/webdav/ Path PROPPATCH /remote.php/webdav/Path MKCOL /remote.php/webdav/Directory DELETE /remote.php/webdav/Directory
  • 23.
    BeGood Technology Etc.. SSSSeeeeccccttttiiiioooonnnn DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Classloader The classloader is provided by ownCloud and loads all your classes automatically. Background Jobs (Cron) Background/cron jobs are usually registered in the appinfo/app.php by using the addRegularTask method Logging The logger can be injected from the ServerContainer Dependency Injection This class extends Pimple for reusability To use this class, extend your own container from this. External API The external API inside ownCloud allows third party developers to access data provided by ownCloud apps. Translation Translation String are shown by editing l10n File To translate Theming Themes can be used to customize the look and feel of ownCloud.
  • 24.
    BeGood Technology Try Startup https://aws.amazon.com/marketplace/pp/B00F8I7IXG/ v7.0.2を選択 してください (申請中。。) Sample https://github.com/ukitiyan/helloworld
  • 25.
    BeGood Technology ご清聴 ありがとうございました。