Giter Club home page Giter Club logo

pomm's Introduction

POMM: The PHP Object Model Manager for Postgresql

https://secure.travis-ci.org/chanmix51/Pomm.png?branch=1.1 https://poser.pugx.org/Pomm/Pomm/version.png https://poser.pugx.org/Pomm/Pomm/d/total.png

This is the stable branch of Pomm. It is devoted for bug corrections and security updates, no more functionalities will be added in this version. You can use it in production or to test Pomm's features.

What is Pomm ?

Pomm is a lightweight, fast, efficient and powerful PHP object manager for the Postgresql relational database. Pomm is not an ORM, it is more like an object hydrator above PDO implementing the identity map design pattern and proposing convenient functionalities. Dropping the abstraction layer makes programmers able to take advantage of most of Postgresql's awesome features.

Pomm works with PHP 5.3 and Postgresql 8.4 and above.

You can reach

What does Pomm propose ?

  • Database introspection and model generation
  • Lazy hydration and on the fly type conversion
  • SQL queries, virtual fields, finders and pagers
  • Collection, filters and query filters
  • A Where clause builder
  • Security and debugging tools

Database introspection and model generation

Once you have designed your database using your favorite tool, Pomm can generate PHP model classes for you by inspecting tables and views. It checks the schema where your database objects are stored so generated classes use according PHP namespaces, there will not be naming collision anymore ! Of Course, Postgresql's table inheritance is supported.

Lazy hydration and on the fly type conversion

Queries return collections which are scrollable iterators on results. Fetched objects are hydrated on demand for minimal memory consumption and data are converted from/to Postgresql. Boolean in Pg are boolean in PHP, arrays in Pg are arrays in PHP, geometric types are converted into geometric PHP objects. Of course this is extensible and custom database types can be converted into custom PHP classes. Almost all standard and geometric types are supported plus range, HStore and ltree extensions.

SQL queries, virtual fields, finders and pagers

Of course 80% of the queries of a web applications are like SELECT * FROM my_table WHERE ... So there is a method for that. You can configure what you do want in the select fields in case you would like to add your classes extra properties. You can even use them with the converter system with extra fields adding them as virtual fields. For the more complicated queries, SQL is the way to go. You can use all the awesome operators, full text search, window functions, CTEs and recursive queries, (add your preferred feature here).

Collection filters and query filters

When retrieving data from the database trough a Collection object, it is possible to register PHP anonymous functions as filters before objects are hydrated. This is very powerful as you can create foreign objects or code you own filters.

Queries are also made in a Filter Chain design pattern. You can add your own filters to place code before and/or after each query.

A Where clause builder

Sometimes, you want to create a WHERE clause dynamically. Pomm proposes a Where class to let you AND and/or OR your conditions passing the values as argument each time for escaping. There is even a WhereIn method with an array of values as parameter.

Security and debugging tools

All queries are prepared, the values you give as argument are automatically escaped by the server. Furthermore, the converter system ensures there is no type enforcing.

To be sure everything is fine, you can register the LoggerFilter to your connection so you will keep track of every query with statistics like the time it took, the number of results returned etc.

How to install Pomm ?

The easy way: composer

Using composer installer and autoloader is probably the easiest way to install Pomm and get it running. What you need is just a composer.json file in the root directory of your project:

{
"require": {
    "pomm/pomm": "master-dev"
  }
}

Invoking composer.phar will automagically download Pomm, install it in a vendor directory and set up the according autoloader. Check out this tutorial for step by step explanation.

Using Pomm with a PHP framework

How to contribute to Pomm ?

That's very easy with github:

  • Send feedback to @PommProject on twitter or by mail at <hubert DOT greg AT gmail DOT com>
  • Report bugs (very appreciated)
  • Fork and PR (very very appreciated)
  • Send vacuum tubes to the author (actual preferred are russians 6Φ12Π, 6Ж43Π, 6Ж38Π, 6C19Π)

Running tests

psql -c 'CREATE DATABASE pomm_test' -U postgres -h 127.0.0.1
psql -c 'CREATE EXTENSION hstore' -U postgres -h 127.0.0.1 pomm_test
psql -c 'CREATE EXTENSION ltree' -U postgres -h 127.0.0.1 pomm_test

phpunit --configuration tests/phpunit.travis.xml

pomm's People

Contributors

adrienbrault avatar brikou avatar chanmix51 avatar daniloassis avatar docteurklein avatar eneault avatar fabiend avatar jeremyfreeagent avatar kcivey avatar kletord avatar pborreli avatar sanpii avatar xavierbriand avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.