Skip to content

Commit 5dc19f7

Browse files
committed
Removed CloudFlare Manager
1 parent b3bb91c commit 5dc19f7

File tree

12 files changed

+21
-324
lines changed

12 files changed

+21
-324
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ This package provides convenient access to the Cloudflare REST API using PHP.
3030

3131
* PHP >= 8.0
3232
* Minimal API around the [Guzzle HTTP client](https://github.com/guzzle/guzzle)
33+
* Light and fast thanks to lazy loading of API classes
34+
* Extensively documented
3335
* Laravel >= 9 support
3436

3537
## Quick install 🚀
@@ -46,7 +48,7 @@ composer require sergkeim/php-cloudflare-api
4648

4749
* Thanks to [Cloudflare](https://developers.cloudflare.com/api/) for the high quality API and documentation.
4850
* Thanks to [KnpLabs](https://github.com/KnpLabs) for [php-github-api](https://github.com/KnpLabs/php-github-api) used as inspiration for this package.
49-
* Thanks to [Graham Campbell](https://github.com/GrahamCampbell) for [Laravel-GitHub](https://github.com/GrahamCampbell/Laravel-GitHub), [Laravel Manager](https://github.com/GrahamCampbell/Laravel-Manager?tab=readme-ov-file) and [Laravel TestBench](https://github.com/GrahamCampbell/Laravel-TestBench).
51+
* Thanks to [Graham Campbell](https://github.com/GrahamCampbell) for [Laravel TestBench](https://github.com/GrahamCampbell/Laravel-TestBench).
5052

5153
## License 📎
5254

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"php": "^8.0",
2323
"guzzlehttp/guzzle": "^7.9",
2424
"illuminate/contracts": "^9.0 || ^10.0 || ^11.0",
25-
"illuminate/support": "^9.0 || ^10.0 || ^11.0",
26-
"graham-campbell/manager": "^5.1"
25+
"illuminate/support": "^9.0 || ^10.0 || ^11.0"
2726
},
2827
"require-dev": {
2928
"phpunit/phpunit": "^9.6.17 || ^10.5.13",

config/cloudflare.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,5 @@
66

77
return [
88

9-
/*
10-
|--------------------------------------------------------------------------
11-
| Default Connection Name
12-
|--------------------------------------------------------------------------
13-
|
14-
| Here you may specify which of the connections below you wish to use as
15-
| your default connection for all work. Of course, you may use many
16-
| connections at once using the manager class.
17-
|
18-
*/
19-
20-
'default' => 'main',
21-
22-
/*
23-
|--------------------------------------------------------------------------
24-
| Cloudflare Connections
25-
|--------------------------------------------------------------------------
26-
|
27-
| Here are each of the connections setup for your application. Example
28-
| configuration has been included, but you may add as many connections as
29-
| you would like.
30-
|
31-
*/
32-
33-
'connections' => [
34-
35-
'main' => [
36-
'token' => 'your-token',
37-
],
38-
39-
'secondary' => [
40-
'token' => 'your-token',
41-
],
42-
],
43-
9+
'token' => 'your-token',
4410
];

docs/content/0.index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ This package provides convenient access to the Cloudflare REST API using PHP.
2929
::list
3030
- PHP >= 8.0
3131
- Minimal API around the [Guzzle HTTP client](https://github.com/guzzle/guzzle)
32+
- Light and fast thanks to lazy loading of API classes
33+
- Extensively documented
3234
- Laravel >= 9 support [see Laravel Usage](/getting-started/laravel)
3335
::
3436

docs/content/1.getting-started/4.laravel.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,21 @@ php artisan vendor:publish
2424

2525
This will create a `config/cloudflare.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.
2626

27-
There are two config options:
28-
29-
##### Default Connection Name
30-
31-
This option (`'default'`) is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is `'main'`.
32-
33-
##### Cloudflare Connections
34-
35-
This option (`'connections'`) is where each of the connections are setup for your application. Example configuration has been included, but you may add as many connections as you would like..
36-
3727
## Usage
3828

3929
##### CloudflareManager
4030

41-
`CloudflareManager` is bound to the ioc container as `'cloudflare'` and can be accessed using the `Facades\Cloudflare` facade.
42-
43-
This class implements the `ManagerInterface` by extending `AbstractManager`. The interface and abstract class are both part of [Graham Campbell - Laravel Manager](https://github.com/GrahamCampbell/Laravel-Manager) package, so you may want to go and checkout the docs for how to use the manager class over at [that repo](https://github.com/GrahamCampbell/Laravel-Manager#usage).
44-
45-
**Note**: that the connection class returned will always be an instance of `Cloudflare\Client`.
31+
`Cloudflare\Client` is bound to the ioc container as `'cloudflare'` and can be accessed using the `Facades\Cloudflare` facade.
4632

4733
##### Facades\Cloudflare
4834

49-
This facade will dynamically pass static method calls to the `'cloudflare'` object in the ioc container which by default is the `CloudflareManager` class.
35+
This facade will dynamically pass static method calls to the `'cloudflare'` object in the ioc container which by default is the `Cloudflare\Client` class.
5036

5137
##### CloudflareServiceProvider
5238

5339
This class contains no public methods of interest. This class should be added to the providers array in `config/app.php`. This class will setup ioc bindings.
5440

55-
Here you can see an example of just how simple this package is to use. Out of the box, the default adapter is `main`. After you enter your `token` in the config file, it will just work:
41+
Here you can see an example of just how simple this package is to use. Out of the box. After you enter your `token` in the config file, it will just work:
5642

5743
```php [php]
5844
use Cloudflare\Facades\Cloudflare;
@@ -65,25 +51,16 @@ Cloudflare::accounts()->list();
6551
Cloudflare::accounts()->details('ACCOUNT_ID');
6652
```
6753

68-
The cloudflare manager will behave like it is a `Cloudflare\Client` class. If you want to call specific connections, you can do with the `connection` method:
69-
70-
```php [php]
71-
use Cloudflare\Facades\Cloudflare;
72-
73-
// the secondary connection is the other example provided in the default config
74-
Cloudflare::connection('secondary')->accounts()->members()->details('ACCOUNT_ID', 'MEMBER_ID');
75-
```
76-
7754
If you prefer to use dependency injection over facades, then you can easily inject the manager like so:
7855

7956
```php [php]
80-
use Cloudflare\CloudflareManager;
57+
use Cloudflare\Client;
8158

8259
class Foo
8360
{
8461

8562
public function __construct(
86-
private CloudflareManager $cloudflare
63+
private Client $cloudflare
8764
) {
8865

8966
}

src/CloudflareFactory.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/CloudflareManager.php

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/CloudflareServiceProvider.php

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -44,56 +44,21 @@ private function setupConfig(): void
4444
*/
4545
public function register(): void
4646
{
47-
$this->registerCloudflareFactory();
48-
$this->registerManager();
49-
$this->registerBindings();
47+
$this->registerCloudflare();
5048
}
5149

5250
/**
53-
* Register the github factory class.
51+
* Register the Cloudflare Client class.
5452
*
5553
* @return void
5654
*/
57-
private function registerCloudflareFactory(): void
55+
private function registerCloudflare(): void
5856
{
59-
$this->app->singleton('cloudflare.factory', function (Container $app): CloudflareFactory {
60-
return new CloudflareFactory();
57+
$this->app->singleton('cloudflare', function (Container $app): Client {
58+
return new Client(config('cloudflare.token'));
6159
});
6260

63-
$this->app->alias('cloudflare.factory', CloudflareFactory::class);
64-
}
65-
66-
/**
67-
* Register the manager class.
68-
*
69-
* @return void
70-
*/
71-
private function registerManager(): void
72-
{
73-
$this->app->singleton('cloudflare', function (Container $app): CloudflareManager {
74-
$config = $app['config'];
75-
$factory = $app['cloudflare.factory'];
76-
77-
return new CloudflareManager($config, $factory);
78-
});
79-
80-
$this->app->alias('cloudflare', CloudflareManager::class);
81-
}
82-
83-
/**
84-
* Register the bindings.
85-
*
86-
* @return void
87-
*/
88-
private function registerBindings(): void
89-
{
90-
$this->app->bind('cloudflare.connection', function (Container $app): Client {
91-
$manager = $app['cloudflare'];
92-
93-
return $manager->connection();
94-
});
95-
96-
$this->app->alias('cloudflare.connection', Client::class);
61+
$this->app->alias('cloudflare', Client::class);
9762
}
9863

9964
/**
@@ -104,9 +69,7 @@ private function registerBindings(): void
10469
public function provides(): array
10570
{
10671
return [
107-
'cloudflare.factory',
10872
'cloudflare',
109-
'cloudflare.connection',
11073
];
11174
}
11275
}

test/Tests/Laravel/CloudflareFactoryTest.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)