Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 146 lines (92 sloc) 7.674 kB
4876eab @bergie started with a README
bergie authored
1 Midgard2 PHP Content Repository provider
2 ========================================
3
630239f @bergie MySQL config example
bergie authored
4 This project implements a [Midgard2](http://midgard2.org/) -backed provider of the [PHP Content Repository](http://phpcr.github.com/) (PHPCR) interfaces. `phpcr-midgard2` is a fully [Jackalope](http://jackalope.github.com/) compatible PHPCR provider that can be used in PHP Content Management Systems without requiring Java.
4876eab @bergie started with a README
bergie authored
5
630239f @bergie MySQL config example
bergie authored
6 Using Midgard2 instead of [Apache Jackrabbit](http://jackrabbit.apache.org/) also has the benefit of making interoperability with regular relational databases used by many CMSs easy. Midgard2 supports [multiple databases](http://www.gnome-db.org/Providers_status), including MySQL and SQLite.
4876eab @bergie started with a README
bergie authored
7
aa783c1 @bergie Get PHPCR via Composer, use Composer-generated autoloader
bergie authored
8 ## Installing
9
d516134 @bergie Some docs on installation and usage
bergie authored
10 You need to have a [midgard2 PHP extension](https://github.com/midgardproject/midgard-php5) installed. On many distributions setting this up is as simple as:
11
12 $ sudo apt-get install php5-midgard2
13
50c85c5 @bergie Link to Midgard2 packages on OBS
bergie authored
14 If your distribution doesn't come with Midgard2, then you can either compile it manually or use [our precompiled packages](http://download.opensuse.org/repositories/home:/midgardproject:/ratatoskr/).
15
d516134 @bergie Some docs on installation and usage
bergie authored
16 Then set your project to depend on `midgard/phpcr` by having your `composer.json` to include:
17
18 "require": {
19 "midgard/phpcr": ">=0.1"
20 }
21
22 Then just install the provider via [Composer](http://packagist.org/):
23
aa783c1 @bergie Get PHPCR via Composer, use Composer-generated autoloader
bergie authored
24 $ wget http://getcomposer.org/composer.phar
25 $ php composer.phar install
26
630239f @bergie MySQL config example
bergie authored
27 You also need to copy the Midgard2 PHPCR schemas from `vendor/midgard/phpcr/data/share/schema` to your schema directory (by default `/usr/share/midgard2/schema`).
d516134 @bergie Some docs on installation and usage
bergie authored
28
29 ## Getting started
30
31 You can use the Composer-generated autoloader to load all needed classes:
32
33 require 'vendor/.composer/autoload.php';
34
35 After you've included the autoloader you should be able to open a Midgard2 repository session:
36
37 // Set up Midgard2 connection
38 $parameters = array(
39 // Use local SQLite file for storage
40 'midgard2.configuration.db.type' => 'SQLite',
41 'midgard2.configuration.db.name' => 'midgard2cr',
42 'midgard2.configuration.db.dir' => __DIR__,
630239f @bergie MySQL config example
bergie authored
43 // Where you want to store file attachments
44 'midgard2.configuration.blobdir' => '/var/lib/midgard2/blobs',
d516134 @bergie Some docs on installation and usage
bergie authored
45 // Let Midgard2 initialize the DB as needed
46 'midgard2.configuration.db.init' => true,
47 );
48
49 // Get a Midgard repository
50 $repository = Midgard\PHPCR\RepositoryFactory::getRepository($parameters);
51
52 // Log in to get a session
53 $credentials = new \PHPCR\SimpleCredentials('admin', 'password');
54 $session = $repository->login($credentials, 'default');
55
56 After this the whole [PHPCR API](http://phpcr.github.com/doc/html/index.html) will be available. See some example code in the [examples` directory](https://github.com/bergie/phpcr-midgard2/tree/master/examples).
57
630239f @bergie MySQL config example
bergie authored
58 With MySQL, the connection parameters could for example be:
59
60 $parameters = array(
61 // MySQL connection settings. The database has to exist
62 'midgard2.connection.db.type' => 'MySQL',
63 'midgard2.connection.db.name' => 'midgard2',
64 'midgard2.connection.db.username' => 'midgard',
65 'midgard2.connection.db.password' => 'midgard',
66 'midgard2.connection.db.host' => '127.0.0.1',
67 'midgard2.connection.db.port' => '3306'
68 // Let Midgard2 initialize the DB as needed
69 'midgard2.configuration.db.init' => true,
70 );
71
72 This is the only different part from the example using SQLite above.
73
ebb6c04 @bergie Quick explanation about PHPCR
bergie authored
74 ## About PHPCR
75
76 The PHP Content Repository API is a PHP version of the Java Content Repository specification. [From Wikipedia](http://en.wikipedia.org/wiki/Content_repository_API_for_Java):
77
78 > Content Repository API for Java (JCR) is a specification for a Java platform application programming interface (API) to access content repositories in a uniform manner. The content repositories are used in content management systems to keep the content data and also the metadata used in content management systems (CMS) such as versioning metadata.
79
80 This way a content management system, for example, would not be tied to a particular database or other storage scheme. Instead, the content repository providers could be chosen based on deployment requirements.
81
82 There is currently [discussion about including](http://java.net/jira/browse/JSR_333-28) PHPCR APIs into the Java Content Repository specification.
83
4876eab @bergie started with a README
bergie authored
84 ## About Midgard2
85
d516134 @bergie Some docs on installation and usage
bergie authored
86 Midgard2 is an open source content repository library available for multiple programming languages.
4876eab @bergie started with a README
bergie authored
87
d516134 @bergie Some docs on installation and usage
bergie authored
88 Midgard2 is able to access and manage content stored in various common relational databases, including SQLite, MySQL and Postgres. For this, you get a reasonably simple object-oriented interface. An example:
4876eab @bergie started with a README
bergie authored
89
90 $article = new net_example_article();
91 $article->title = "Hello, world";
92 $article->create();
93 echo "Article {$article->title} was stored with GUID {$article->guid}";
94
95 ## PHPCR and Midgard2
96
6a222d2 @bergie Update tree model info in README
bergie authored
97 There have been [some studies](http://bergie.iki.fi/blog/what_is_a_content_repository/) into the conceptual differences and similarities between the Midgard2 Content Repository model and the [Java Content Repository](http://en.wikipedia.org/wiki/Content_repository_API_for_Java) model used in PHPCR. Because of these differences, some conceptual mappings are needed.
4876eab @bergie started with a README
bergie authored
98
6a222d2 @bergie Update tree model info in README
bergie authored
99 * Repository = Midgard config
4876eab @bergie started with a README
bergie authored
100 * Session = Midgard connection
101 * Node = Midgard object
6a222d2 @bergie Update tree model info in README
bergie authored
102 * Node Type = MgdSchema
4876eab @bergie started with a README
bergie authored
103 * Property = Property or Parameter of Midgard object
6a222d2 @bergie Update tree model info in README
bergie authored
104 * Workspace = Midgard workspace
4876eab @bergie started with a README
bergie authored
105
3034c02 @bergie Properties as parameters
bergie authored
106 ### Making the Midgard tree single-rooted
107
6a222d2 @bergie Update tree model info in README
bergie authored
108 The Midgard PHPCR tree is built out of `midgard_node` objects. These objects are only used for building the tree, and are connected to the real content objects in the tree by their `objectguid` property.
aedd017 @bergie Root node mapping
bergie authored
109
6a222d2 @bergie Update tree model info in README
bergie authored
110 Properties that are not managed by MgdSchemas (so, properties not registered to Node Types) are handled by `midgard_node_property` objects.
aedd017 @bergie Root node mapping
bergie authored
111
714abc1 @bergie Clarifying workspaces usage
bergie authored
112 ### Workspaces
aedd017 @bergie Root node mapping
bergie authored
113
714abc1 @bergie Clarifying workspaces usage
bergie authored
114 When Midgard2's own [Workspaces implementation](http://www.midgard-project.org/development/mrfc/0042/) lands in 10.05.5, we will support using [JCR Workspaces](http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Workspace.html) as well. The workspace strings will be in format:
115
116 * `workspace`
117 * `workspace/subworkspace`
aedd017 @bergie Root node mapping
bergie authored
118
3034c02 @bergie Properties as parameters
bergie authored
119 ### Namespace mappings
120
121 The PHPCR API uses namespaces for node types and property names. The regular [Midgard2 MgdSchema RDF mappings](https://github.com/midgardproject/proposals/blob/master/Semantic%20Data/MgdSchemaRDF.md) should be used for this.
122
aedd017 @bergie Root node mapping
bergie authored
123 ## Projects using PHPCR
124
125 * [Symfony CMF](http://pooteeweet.org/blog/0/1912#m1912)
630239f @bergie MySQL config example
bergie authored
126 * [Doctrine ODM](https://github.com/doctrine/phpcr-odm)
aedd017 @bergie Root node mapping
bergie authored
127 * Flow3/TYPO3
4876eab @bergie started with a README
bergie authored
128
699bbee @bergie Licensing note
bergie authored
129 ## Licensing
130
131 Content Repositories are important piece of software infrastructure that must be usable by any projects or companies regardless of their business model. Because of this, the Midgard2 PHPCR implementation will be available under permissive terms of the [GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl-2.1.html).
132
4876eab @bergie started with a README
bergie authored
133 ## Development
134
135 Contributions to the Midgard2 PHPCR provider are very much appreciated. The development is coordinated on a GitHub repository:
136
4808701 @bergie Update repo URLs
bergie authored
137 * [github.com/midgardproject/phpcr-midgard2](https://github.com/midgardproject/phpcr-midgard2)
4876eab @bergie started with a README
bergie authored
138
4808701 @bergie Update repo URLs
bergie authored
139 Feel free to watch the repository, make a fork and [submit pull requests](http://help.github.com/pull-requests/). Code reviews, testing and [bug reports](https://github.com/midgardproject/phpcr-midgard2/issues) are also very welcome.
6a222d2 @bergie Update tree model info in README
bergie authored
140
141 ### Continuous Integration
142
143 The Midgard2 PHPCR provider is using [Travis](http://travis-ci.org) for Continuous Integration.
144
145 If you have a fork of this repository and want it tested, enable it on the Travis website. Each push will be automatically tested.
Something went wrong with that request. Please try again.