Giter VIP home page Giter VIP logo

php-sdk's Introduction

Any language, any framework, anywhere

Go Report OpenSSF Docker Pulls Build Status Test Status Code Coverage License: Apache 2.0 FOSSA Status TODOs Good First Issues discord YouTube X/Twitter

Dapr is a portable, serverless, event-driven runtime that makes it easy for developers to build resilient, stateless and stateful microservices that run on the cloud and edge and embraces the diversity of languages and developer frameworks.

Dapr codifies the best practices for building microservice applications into open, independent, building blocks that enable you to build portable applications with the language and framework of your choice. Each building block is independent and you can use one, some, or all of them in your application.

Dapr overview

We are a Cloud Native Computing Foundation (CNCF) incubation project.

Goals

  • Enable developers using any language or framework to write distributed applications
  • Solve the hard problems developers face building microservice applications by providing best practice building blocks
  • Be community driven, open and vendor neutral
  • Gain new contributors
  • Provide consistency and portability through open APIs
  • Be platform agnostic across cloud and edge
  • Embrace extensibility and provide pluggable components without vendor lock-in
  • Enable IoT and edge scenarios by being highly performant and lightweight
  • Be incrementally adoptable from existing code, with no runtime dependency

How it works

Dapr injects a side-car (container or process) to each compute unit. The side-car interacts with event triggers and communicates with the compute unit via standard HTTP or gRPC protocols. This enables Dapr to support all existing and future programming languages without requiring you to import frameworks or libraries.

Dapr offers built-in state management, reliable messaging (at least once delivery), triggers and bindings through standard HTTP verbs or gRPC interfaces. This allows you to write stateless, stateful and actor-like services following the same programming paradigm. You can freely choose consistency model, threading model and message delivery patterns.

Dapr runs natively on Kubernetes, as a self hosted binary on your machine, on an IoT device, or as a container that can be injected into any system, in the cloud or on-premises.

Dapr uses pluggable component state stores and message buses such as Redis as well as gRPC to offer a wide range of communication methods, including direct dapr-to-dapr using gRPC and async Pub-Sub with guaranteed delivery and at-least-once semantics.

Why Dapr?

Writing highly performant, scalable and reliable distributed application is hard. Dapr brings proven patterns and practices to you. It unifies event-driven and actors semantics into a simple, consistent programming model. It supports all programming languages without framework lock-in. You are not exposed to low-level primitives such as threading, concurrency control, partitioning and scaling. Instead, you can write your code by implementing a simple web server using familiar web frameworks of your choice.

Dapr is flexible in threading and state consistency models. You can leverage multi-threading if you choose to, and you can choose among different consistency models. This flexibility enables you to implement advanced scenarios without artificial constraints. Dapr is unique because you can transition seamlessly between platforms and underlying implementations without rewriting your code.

Features

  • Event-driven Pub-Sub system with pluggable providers and at-least-once semantics
  • Input and output bindings with pluggable providers
  • State management with pluggable data stores
  • Consistent service-to-service discovery and invocation
  • Opt-in stateful models: Strong/Eventual consistency, First-write/Last-write wins
  • Cross platform virtual actors
  • Secret management to retrieve secrets from secure key vaults
  • Rate limiting
  • Built-in Observability support
  • Runs natively on Kubernetes using a dedicated Operator and CRDs
  • Supports all programming languages via HTTP and gRPC
  • Multi-Cloud, open components (bindings, pub-sub, state) from Azure, AWS, GCP
  • Runs anywhere, as a process or containerized
  • Lightweight (58MB binary, 4MB physical memory)
  • Runs as a sidecar - removes the need for special SDKs or libraries
  • Dedicated CLI - developer friendly experience with easy debugging
  • Clients for Java, .NET Core, Go, Javascript, Python, Rust and C++

Get Started using Dapr

See our Getting Started guide over in our docs.

Quickstarts and Samples

Community

We want your contributions and suggestions! One of the easiest ways to contribute is to participate in discussions on the mailing list, chat on IM or the bi-weekly community calls. For more information on the community engagement, developer and contributing guidelines and more, head over to the Dapr community repo.

Contact Us

Reach out with any questions you may have and we'll make sure to answer them as soon as possible!

Platform Link
๐Ÿ’ฌ Instant Message Chat (preferred) Discord Banner
๐Ÿ“ง Mailing List https://groups.google.com/forum/#!forum/dapr-dev
๐Ÿค Twitter @daprdev

Community Call

Every two weeks we host a community call to showcase new features, review upcoming milestones, and engage in a Q&A. All are welcome!

๐Ÿ“ž Visit https://aka.ms/dapr-community-call for upcoming dates and the meeting link.

Videos and Podcasts

We have a variety of keynotes, podcasts, and presentations available to reference and learn from.

๐Ÿ“บ Visit https://docs.dapr.io/contributing/presentations/ for previous talks and slide decks.

Contributing to Dapr

See the Development Guide to get started with building and developing.

Repositories

Repo Description
Dapr The main repository that you are currently in. Contains the Dapr runtime code and overview documentation.
CLI The Dapr CLI allows you to setup Dapr on your local dev machine or on a Kubernetes cluster, provides debugging support, launches and manages Dapr instances.
Docs The documentation for Dapr.
Quickstarts This repository contains a series of simple code samples that highlight the main Dapr capabilities.
Samples This repository holds community maintained samples for various Dapr use cases.
Components-contrib The purpose of components contrib is to provide open, community driven reusable components for building distributed applications.
Dashboard General purpose dashboard for Dapr
Go-sdk Dapr SDK for Go
Java-sdk Dapr SDK for Java
JS-sdk Dapr SDK for JavaScript
Python-sdk Dapr SDK for Python
Dotnet-sdk Dapr SDK for .NET
Rust-sdk Dapr SDK for Rust
Cpp-sdk Dapr SDK for C++
PHP-sdk Dapr SDK for PHP

Code of Conduct

Please refer to our Dapr Community Code of Conduct

php-sdk's People

Contributors

aaroncrawfis avatar aquamme avatar github-actions[bot] avatar greenie-msft avatar hendrikheil avatar msfussell avatar withinboredom avatar yaron2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-sdk's Issues

Cloud Events require custom header

Expected Behavior

Publishing Cloud Events should work.

Actual Behavior

Cloud Events do not work.

Steps to Reproduce the Problem

Run integration tests on latest release candidate.

See: dapr/docs#1130

Release Note

RELEASE NOTE: FIX Cloud Events shouldn't be wrapped in a Cloud Event

Updates for next runtime RC

Update the SDK for the following breaking changes:

  1. Service invocation now handles queryparams as string and not Map of string->string. Get the latest proto and fix any code in the SDK that refers to that. I assume there is no need to handle this in the PHP SDK because it does not use gRPC.

  2. When content type is "application/octet-stream", CloudEvent's data will now be in data_base64 and that should be exposed as byte[] to the application.

(De)Serializer should be fully pluggable

Currently, the developer may replace the serializer/deserializer with their own implementation, however, this is the same serializer and deserializer that the SDK uses for communicating with the sidecar. This is a simple configuration change to fix and not a breaking change.

Add mutation tests

Bugs and security issues result from data being unexpected and the code still continuing anyway.

Serializing/deserializing complex types between SDKs should work

Expected Behavior

Given the dotnet classes:

public class WeatherForecastWithPOCOs
{
    public DateTimeOffset Date { get; set; }
    public int TemperatureCelsius { get; set; }
    public string Summary { get; set; }
    public string SummaryField;
    public IList<DateTimeOffset> DatesAvailable { get; set; }
    public Dictionary<string, HighLowTemps> TemperatureRanges { get; set; }
    public string[] SummaryWords { get; set; }
}

public class HighLowTemps
{
    public int High { get; set; }
    public int Low { get; set; }
}

results in the following json object:

{
  "Date": "2019-08-01T00:00:00-07:00",
  "TemperatureCelsius": 25,
  "Summary": "Hot",
  "DatesAvailable": [
    "2019-08-01T00:00:00-07:00",
    "2019-08-02T00:00:00-07:00"
  ],
  "TemperatureRanges": {
    "Cold": {
      "High": 20,
      "Low": -10
    },
    "Hot": {
      "High": 60,
      "Low": 20
    }
  },
  "SummaryWords": [
    "Cool",
    "Windy",
    "Humid"
  ]
}

Which should be handled with the following PHP classes:

class WeatherForecastWithPOPOs
{
    public DateTime $Date;
    public int $TemperatureCelsius;
    public string $Summary;
    public string $SummaryField;
    #[CastValues(DateTime::class)]
    public array $DatesAvailable;
    #[CastValues(HighLowTemps::class)]
    public array $TemperatureRanges;
    public array $SummaryWords;
}

class HighLowTemps
{
    public int $High;
    public int $Low;
}

Actual Behavior

Deserialized as an array.

Steps to Reproduce the Problem

See above

Release Note

RELEASE NOTE: Fix Deserialization of complex types from other SDKs

Document 1.2 changes and migrations

Describe the feature

SDK version 1.2 includes a new dapr client and begins the deprecation of few classes. The changes need to be documented in dapr docs site and in the readme.

Migration from 1.1 to 1.2 needs to be documented, though it is pretty straightforward.

Release Note

RELEASE NOTE: ADD documentation for 1.2

Allow not waiting for a method to return

Describe the feature

Sometimes when calling an actor method, you need the response. Other times, you don't.

It would be nice if there was some way to say that you don't want to call wait for the response. In languages like C#, you can choose to wait for the response, or you can "fire and forget it" by not awaiting the async call.

In PHP, this is not possible because it's a synchronous language by default. This should mostly be considered when optimizing time spent in functions or when something needs to be started that takes a long time to run.

Proposal

Add a function nowait() that accepts a callable, the function sets a "magic variable" which lets the proxy know not to wait for the response, only while executing the callable.

Alternatively, we could create an await() function that does the opposite, and method calls are normally "fire and forget." I don't really like this idea because it seems to be counter-intuitive in PHP.

This could also be a configuration argument when getting an actor proxy.

Release Note

RELEASE NOTE: ADD Fire and forget API calls

Support Dapr API Token

Describe the feature

The Dapr Client should send the DAPR_API_TOKEN if it is set.

Release Note

RELEASE NOTE: ADD Dapr API token support

Use attributes for better method definitions

Describe the proposal

During yesterday's community call, I was inspired by the dotnet-sdk's use of attributes to define where data comes from in API calls. I think something like this would be really handy:

$method = #[HttpMethod('GET', 'POST') function myMethod(#[FromUrl('/d+')] $id, #[FromBody] $data) {
 return 'ok';
}
Runtime::register_method($method);

Add Documentation

Describe the feature

Add deeper documentation on using the SDK and any details.

Release Note

RELEASE NOTE: ADD Documentation

Optimize actors

We have a few guarantees from the Actor system, for example, we know there's no other instance of an actor running elsewhere in the cluster and no other instance of PHP is being called.

That being said, we can use the filesystem to cache state between requests. That way we can avoid reading the same state from the store when it hasn't changed.

The general flow will look like this:

  1. Activation: if there is a filesystem cache, delete it (unclean deactivation)
  2. If there is a filesystem cache, read it
  3. Commit the transaction
  4. Commit state to filesystem cache
  5. Deactivation: delete the filesystem cache

Logging

Describe the feature

  • Should support monolog.
  • Review all logging output and ensure it adds usefulness.

Release Note

RELEASE NOTE: ADD monolog

Dapr composer org, package and publish

Currently, in the readme, we have composer require dapr/php-sdk. However, we don't currently have a composer org.

We should create it. Also, I'm not sure on the name of the package. php-sdk seems kinda redundant.

Actor state doesn't work with cosmosdb

Expected Behavior

Actors should work

Actual Behavior

The SDK isn't using the single get endpoint, but rather using the more generic bulk state endpoint. This causes an issue with cosmos db (and potentially other components) because the component uses the name of the key as the partition key, however, the actor identity should be the partition key.

Steps to Reproduce the Problem

  1. Set up cosmosdb component
  2. Use ngrok to proxy the component, for example: ngrok http -hostname=ENDPOINT.eu.ngrok.io -region eu -host-header=rewrite https://COSMOS_DB.documents.azure.com:443/
  3. See the X-Ms-Documentdb-Partitionkey header set on loading keys be set to the full key. It should be the actor id, or not set at all and be a cross partition query.

Release Note

RELEASE NOTE: FIX actors with cosmosdb

Exceptions are Opaque

Expected Behavior

Exceptions should be more transparent about what happened to allow for better debugging.

Actual Behavior

Exceptions are vague and don't contain any detail.

Steps to Reproduce the Problem

Invoke a stateful method without configuring state.

Release Note

RELEASE NOTE: FIX Make exceptions more transparent.

PHP 8.0.1 released

Expected Behavior

To be able to use the php-sdk with PHP 8.0.1

Actual Behavior

The required PHP version is too strict.

Steps to Reproduce the Problem

  1. Install PHP 8.0.1
  2. Run composer install

Release Note

RELEASE NOTE: FIX PHP version too strict

file_put_contents bug

After learning the hard way, file_put_contents may not flush the file to disk (it's a very old bug). Caches are written using this function, which may cause intermittent race conditions. The file writing needs to use lower-level functions to write files and ensure it is flushed to disk.

Use examples as e2e tests

Describe the feature

Examples provide a fairly good surface for providing e2e tests. I wonder if we can use the examples directory to provide those tests.

Release Note

RELEASE NOTE: ADD examples as e2e tests

etag mismatch returns a different error code by runtime

Expected Behavior

dapr runtime changes the error code returned by the state apis for etag mismatch related errors and other errors. Check if the sdk needs a change. dapr/dapr#2647

Actual Behavior

Check if sdk needs a change to distinguish between etag mismatch and other state api issues

Steps to Reproduce the Problem

Error code internal is returned when state api fails due to etag mismatch error

Release Note

RELEASE NOTE:

Document 1.2 release

Describe the feature

1.2 is in RC, it just needs documentation

Release Note

RELEASE NOTE:

Add support for actor reentrancy

Describe the feature

The dapr core runtime is planning on supporting actor reentrancy. The bulk of this logic will be handled in dapr's runtime but the SDK will be responsible for:

  • Preserving the header dapr-reentrant-id
  • Providing the new config fields required by dapr/config

For more context on actor reentrancy, the design proposal can be found here: actor reentrancy

Release Note

RELEASE NOTE: ADD Support for actor reentrancy

1.0.0 Code Freeze

The code is frozen until after 1.0.

Only bug-fixes and documentation updates will be merged to main.

Symfony integration

Symfony integration

Do you plan to describe how to integrate DAPR into Symfony properly?

Add upgrade guide for 1.1

Describe the feature

There'll be some new features in 1.1, and a guide needs to be written specifically explaining how to upgrade the code to take advantage of those features.

Release Note

RELEASE NOTE:

Make integration tests great again

Due to the single-threaded nature of the dev server, it's possible the actor tests can hang forever.

  • use docker-compose to start the servers
  • output the logs when there is an error

Add GRPC client

Describe the feature

Dapr supports GPRC which the PHP SDK could benefit from.

Release Note

RELEASE NOTE: ADD GPRC client

Add examples

Describe the feature

The title explains it all!

  • Add a simple counter actor example
  • Binding example
  • Invocation example
  • Pubsub example
  • Secret store example
  • W3C tracing example
  • Examples in docs repo
  • Laravel support and example (#82)
  • Symfony support and example (#88)

Release Note

RELEASE NOTE: ADD Examples

Proxy Types: should match what is expected

There are two proxy types:

  1. ActorProxy
  2. TransactionalState

In older versions of PHP, this is probably ok. However, in PHP 8, which has a much richer type system, this can get in the way.

For example, with an actor's constructor, we must not specify a type for the state because it's being proxied by the TransactionalState proxy. Also, when getting an ActorProxy, we cannot specify the type because it doesn't have one.

Better code generation

Describe the feature

Currently, code generation is home-brewed, it would be a good idea to rely on a library for that.

Release Note

RELEASE NOTE: UPDATE better code generation

Add integration tests to github actions

Describe the feature

Currently, integration tests can only be run manually. They should be automated.

Release Note

RELEASE NOTE: ADD automated integration tests

Add an editorconfig

Formatting is kind-of spotty and inconsistent. It'd be good to have some consistency and have formatting be enforced in PRs.

Support native DateInterval

Describe the feature

Now that dapr/dapr#3095 is merged, we can support native DateInterval instead of constructing a time golang time span

Release Note

RELEASE NOTE: ADD native DateInterval support

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.