Download the PHP package devhammed/server-actions without Composer

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

devhammed/server-actions

Latest Version on Packagist

Making Next.js Server Actions work in PHP!

This is a proof of concept inspired by this tweet, and it's not meant to be used in production.

But it works so let's go!

Installation

The recommended way to install this package is through Composer.

Then include the Composer autoloader in your entry file (e.g index.php) like:

But you can also download this repository and include the provided autoload.php file e.g

Usage

You can use this package in any PHP project, but it has first-class support for Laravel and all the heavy lifting is done for you.

You can skip to the Laravel section if you are using Laravel.

The basic concept is that you have to initialize the Server in your entry file (e.g index.php) before using it by calling the useServer() function without any arguments which will return the instance that you can use to configure the server endpoint and the storage for the server actions which the package currently provides DevHammed\ServerActions\Contracts\ServerEntry interface.

Then you need to create the server actions handler file that was specified in the withServerActionsUrl method e.g server-actions.php that will look almost the same as the entry file but with the run() method called at the end of the chain and nothing else, like:

Then you can use the useServer helper function in the included PHP files like:

Laravel

This package provides a service provider for Laravel that will automatically initialize the server and endpoint for you.

You can register the service provider in your config/app.php file if you are using Laravel 5.4 or below, but if you are using Laravel 5.5 or above, the package will automatically register itself using auto-discovery.

After that, you should run the following command to publish the configuration file to config/server-actions.php and setup other things that might be needed.

Then you can use the useServer helper function in your Blade templates like:

Note that the @csrf directive is required for Laravel to accept the request since this is like every other form request and the handler can be used just like you would use a controller method e.g redirecting, returning a view, etc. which is why we are returning a string instead of echoing it unlike the vanilla PHP example.

That's it! Go make some server actions!

License

This package is open-sourced software licensed under the MIT license.

Credits


All versions of server-actions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
opis/closure Version ^3.6
ramsey/uuid Version ^4.7
illuminate/contracts Version ^10.0
spatie/laravel-package-tools Version ^1.16
illuminate/support Version ^10.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 devhammed/server-actions contains the following files

Loading the files please wait ....