PHPackages                             imsamurai/http-source - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. imsamurai/http-source

ActiveCakephp-plugin[HTTP &amp; Networking](/categories/http)

imsamurai/http-source
=====================

Provides base class for datasorses with Http protocol

1.2.11(10y ago)31.5k3[6 issues](https://github.com/imsamurai/cakephp-httpsource-datasource/issues)4MITPHP

Since Feb 6Pushed 10y ago3 watchersCompare

[ Source](https://github.com/imsamurai/cakephp-httpsource-datasource)[ Packagist](https://packagist.org/packages/imsamurai/http-source)[ Docs](http://github.com/imsamurai/cakephp-httpsource-datasource)[ RSS](/packages/imsamurai-http-source/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (3)Versions (25)Used By (4)

HttpSource Plugin [![Main page](https://camo.githubusercontent.com/852d0c53d97c2e64ed947f496246e6566616a42ee0ca36459b493b5b7b2a9fce/687474703a2f2f696d73616d757261692e6769746875622e696f2f63616b657068702d68747470736f757263652d64617461736f757263652f696d616765732f6f63746f6361742d6c6f676f2e706e67)](http://imsamurai.github.io/cakephp-httpsource-datasource/)
=================================================================================================================================================================================================================================================================================================================================================================

[](#httpsource-plugin-)

[![Build Status](https://camo.githubusercontent.com/bb6a7cbbcf866f5aedbeaf4c0c92fd005e720d46e3c26123f84bd5c203a14242/68747470733a2f2f7472617669732d63692e6f72672f696d73616d757261692f63616b657068702d68747470736f757263652d64617461736f757263652e706e67)](https://travis-ci.org/imsamurai/cakephp-httpsource-datasource) [![Coverage Status](https://camo.githubusercontent.com/545f72419f6b37722a51f62bdcbde8886694e6e35670429f5c37a672da40e19c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f696d73616d757261692f63616b657068702d68747470736f757263652d64617461736f757263652f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/imsamurai/cakephp-httpsource-datasource?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/9aa98c7a08f2e4217b8a1c735369dd240590973acb37003ad4de5f2e13c61a78/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f687474702d736f757263652f762f737461626c652e706e67)](https://packagist.org/packages/imsamurai/http-source) [![Total Downloads](https://camo.githubusercontent.com/9939af96eb58d0696e56c2316852c87a0ed5d3fdcb0005bfb02c86cf87aa0c8f/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f687474702d736f757263652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/imsamurai/http-source) [![Latest Unstable Version](https://camo.githubusercontent.com/61de56b83e6b4fd5f2f0ac45457d155ecaa5f6f1be566a4978f3ab46ed66c953/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f687474702d736f757263652f762f756e737461626c652e706e67)](https://packagist.org/packages/imsamurai/http-source) [![License](https://camo.githubusercontent.com/c2cb7ba4d781d49370ce0e96dafd0549bc0660de88dc4ed86c6fd943eb708e8c/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f687474702d736f757263652f6c6963656e73652e706e67)](https://packagist.org/packages/imsamurai/http-source)

Plugin with HttpSource to provide base class for datasorses with Http protocol. Based on [ProLoser](https://github.com/ProLoser/CakePHP-Api-Datasources) implementation. I make some refactoring to make HttpSource more similar to DboSource and removed OAuth component, because i think for login better use [Opauth](https://github.com/uzyn/cakephp-opauth).

For existing plugins check [ProLoser](https://github.com/ProLoser/CakePHP-Api-Datasources) readme. But they will not work with HttpSource. I will adapt these plugins later.

Notes
-----

[](#notes)

`HttpSource` is an **abstract** class and must be extended by the Api you wish to support. Open a bug ticket if you'd like some help making your own or just want me to do it. It's *very* easy to add new ones - [check out the list](#expanding-functionality)

Installation
------------

[](#installation)

### Step 1: Clone or download to `Plugin/HttpSource`

[](#step-1-clone-or-download-to-pluginhttpsource)

```
cd my_cake_app/app
git clone git://github.com/imsamurai/cakephp-httpsource-datasource.git Plugin/HttpSource

```

or if you use git add as submodule:

```
cd my_cake_app
git submodule add "git://github.com/imsamurai/cakephp-httpsource-datasource.git" "app/Plugin/HttpSource"

```

then update submodules:

```
git submodule init
git submodule update

```

### Step 2: Add your configuration to `database.php` and set it to the model

[](#step-2-add-your-configuration-to-databasephp-and-set-it-to-the-model)

```
:: database.php ::

```

```
var $myapi = array(
	'datasource' => 'MyPlugin.Http/MyPlugin', // Example: 'Github.Http/Github'
        'host' => 'api.myplugin.com/v1',
        'port' => 80,
        'persistent' => false,
		'auth' => array(
			'name' => 'oauth',
			'version' => '1.0', //version 2 not tested, maybe don't work
			'oauth_consumer_key' => '--Your API Key--',
			'oauth_consumer_secret' => '--Your API Secret--'
		),
        //all other parameters that passed to config of http socket
        //...
);
```

```
:: MyModel.php ::

```

```
public $useDbConfig = 'myapi';
public $useTable = 'myapi_table';
```

### Step 3: Load main plugin and your plugin

[](#step-3-load-main-plugin-and-your-plugin)

```
:: bootstrap.php ::

```

```
CakePlugin::load('HttpSource', array('bootstrap' => true, 'routes' => true));
CakePlugin::load('MyPlugin');
```

### Step 4: Querying the API

[](#step-4-querying-the-api)

Best to just give an example. I switch the datasource on the fly because the model is actually a `projects` table in the DB. I tend to query from my API and then switch to default and save the results.

```
App::uses('HttpSourceModel', 'HttpSource.Model');

class Project extends HttpSourceModel {
	function findAuthedUserRepos() {
		$this->setDataSource('github');
		$projects = $this->find('all', array(
                        //used as repo name if useTable is empty, otherwise used as standart fields parameter
			'fields' => 'repos'
		));
		$this->setDataSource('default'); // if more queries are done later
		return $projects;
	}
}
```

Configuration
-------------

[](#configuration)

See [wiki](https://github.com/imsamurai/cakephp-httpsource-datasource/wiki).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 92.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Recently: every ~41 days

Total

24

Last Release

4001d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab9b1bb43e8563f1ff3fd78cb0bf0b28b55026a9f792f2b26aefae882e1512d2?d=identicon)[imsamurai](/maintainers/imsamurai)

---

Top Contributors

[![imsamurai](https://avatars.githubusercontent.com/u/843002?v=4)](https://github.com/imsamurai "imsamurai (133 commits)")[![skalmi](https://avatars.githubusercontent.com/u/752442?v=4)](https://github.com/skalmi "skalmi (6 commits)")[![ProLoser](https://avatars.githubusercontent.com/u/67395?v=4)](https://github.com/ProLoser "ProLoser (3 commits)")[![sime](https://avatars.githubusercontent.com/u/216917?v=4)](https://github.com/sime "sime (2 commits)")

---

Tags

httpplugindatabasecakephpdatasource

### Embed Badge

![Health badge](/badges/imsamurai-http-source/health.svg)

```
[![Health](https://phpackages.com/badges/imsamurai-http-source/health.svg)](https://phpackages.com/packages/imsamurai-http-source)
```

###  Alternatives

[php-http/logger-plugin

PSR-3 Logger plugin for HTTPlug

29025.3M69](/packages/php-http-logger-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
