Download the PHP package davewid/cactus without Composer

On this page you can find all versions of the php package davewid/cactus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cactus

Cactus

Cactus is a ORM using the DataMapper pattern for PHP 5.3+

Example

We will walk through a quick example on how to use Cactus. First we will start with a table called user that we will build our example around.

Working with this structure we can now dive into the model and entity classes.

Mapper

The mapper classes hold all of the information about the database table it is mapping, including the table name and primary key.

Here is the model class for our user table.

The mapper class has no knowledge of how to connect to your data source so you will have to specify that yourself.

As you can see the adapter needs to be injected into the class, so it is probably wise to use a dependency injection container to accomplish this.

See the PDO docs for more information on creating a PDO connection.

Using a framework or don't have PDO available? You are in luck because you can easily create adapters to suit your needs. All you need to do is implement the \Cactus\Adapter interface and inject that adapter into Cactus.

Entity

An entity is a representation of each data row as an object. All validation and data normalization should be contained within the entity.

Below is a sample entity class for our user.

Pretty simple huh?

Querying

There are 3 types of queries built in; finding, saving and deleting.

Find

Save

Delete

Defining Columns

The goal of defining the columns is not to be able to generate the sql to create your tables, but to convert the string values from the database over to native php types.

Lets take a look at the example from UserMapper above

As you can see the columns array is setup in a $name => $type setup. For a full list of field types you can choose from check the documentation for \Cactus\Converter. Setting a field to false keeps it as a string as well.

Building Queries

You can build queries for custom methods in your model anyway you want. Cactus comes bundled with Peyote if you would like to build your queries in an object oriented way.

Supported Adapters

Below is a list of currently supported adapters. If you don't see your framework in the list, hack the code and send a pull request.

Hacking

Cactus is in heavy development and all contributions are welcome and encouraged. Before you start hacking away, make sure you switch over to the develop branch.

Running Tests

Before you send a pull request on any changes, make sure that the phpunit tests pass, adding tests where necessary.

Since this is an ORM, you will need to test a database. To connect to the database you will need to to modify the php section of the phpunit.xml file with your settings. Before you commit changes make sure you run...

git update-index --assume-unchanged phpunit.xml

This way your username/passwords don't get pushed into the repo.


Developed by Dave Widmer


All versions of cactus with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
davewid/peyote Version 0.6.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package davewid/cactus contains the following files

Loading the files please wait ....