Download the PHP package dapr/php-sdk without Composer

On this page you can find all versions of the php package dapr/php-sdk. 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 php-sdk

Using this library

PHP Composer

This library is licensed with the MIT license.

Add the library to your composer.json:

composer require dapr/php-sdk

Some basic documentation is below, more documentation can be found in the docs;

Migrating to 1.2

In preparation for gRPC support in this SDK, there's now a new DaprClient in \Dapr\Client\DaprClient. Please update your code to use the new client.

There shouldn't be many changes to your code to upgrade to 1.2+ from a prior version. Namely, there are some deprecations:

Deprecations

The following have been deprecated and will be removed in 1.4+.

\Dapr\SecretManager has been deprecated

Simply use the new client instead.

\Dapr\Client has been deprecated

Simply use the new client: \Dapr\Client\DaprClient.

\Dapr\PubSub\Publish has been deprecated

Simply instantiate \Dapr\PubSub\Topic directly or use the new client directly.

Fallbacks and Upgrades

\Dapr\State\StateManager

This class has been upgraded to use the new client. It shouldn't require any changes to your code, however, the old behavior can be utilized with \Dapr\State\StateManagerOld.

\Dapr\State\TransactionalState

This class has been upgrade to use the new client. It shouldn't require any changes to your code, however, the old behavior can be utilized with \Dapr\State\TransactionalStateOld.

Creating a Dapr Client

Using the Middleware

The App object also implements a PSR-15 compatible middleware which implements the actor routes and subscribe routes for you.

Accessing Secrets

You can access secrets easily:

Accessing State

There are several ways to access state. You can access state directly via the client or abstract access via an object.

Accessing State Directly

Abstract via Object

Transactional State

You can also use transactional state to interact with state objects by extending TransactionalState with our state objects or commit transactions directly.

Directly with the client

Abstracted via an Object

Actors

Actors are fully implemented and quite powerful. In order to define an actor, you must first define the interface. You'll likely want to put this in a separate library for easy calling from other services.

Once the interface is defined, you'll need to implement the behavior and register the actor.

The state to inject is read from the constructor arguments, the state must derive from ActorState to be injected. You may use as many state classes as you'd like. State is automatically saved for you if you make any changes to it during the method call using transactional state.

The Actor base class gives you access to some helper functions and saves you from writing some boiler-plate. You may also implement IActor and use the ActorTrait as well.

Calling an Actor

In order to call an actor, simply call the ActorProxy and get a proxy object:

You can also call an actor without an interface:

Actor Limitations

  1. There's no re-entrance to an actor, by default. You'll need to enable it in the ActorConfig and in Dapr.
  2. By design, static functions don't work.
  3. There's overhead cost in calling "getter" functions.

More detail here: https://docs.dapr.io/developing-applications/building-blocks/actors/actors-overview/

Pub/Sub

Delivering events around your application is an important aspect of any application. This is supported by Dapr, and implemented in this SDK.

Publishing

In order to publish an event, you just instantiate the Topic object:

or you can use the new client like:

Subscribing

Serializing

If you need to register a custom serializer, you can completely override the built-in serializers on a per-type basis or even the default serializers:

Using the new client

Development

Tests

Simply run composer test to run the unit tests. You can lint using composer lint.

Integration tests

You need docker-compose and jq

Build and start the environment, then run the integration tests and clean up.

You should see output like:


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
laminas/laminas-httphandlerrunner Version ^1.3
monolog/monolog Version ^2.2
nette/php-generator Version ^3.5
nikic/fast-route Version ^1.3
nyholm/psr7 Version ^1.3
nyholm/psr7-server Version ^1.0
php Version ^8.0
php-di/invoker Version ^2.3
php-di/php-di Version ^6.3
psr/log Version ^1.1
psr/http-server-middleware Version >=1.0.1
jetbrains/phpstorm-attributes Version 1.0
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 dapr/php-sdk contains the following files

Loading the files please wait ....