Download the PHP package yuloh/expect without Composer

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

Expect

This package is a pure PHP alternative to expect, the Unix tool. This package doesn't depend on the PECL package either.

Expect lets you script interactions with interactive terminal applications.

Why?

I wrote this because I wrote an interactive CLI program and needed to write automated tests for it. Apparently people use the real expect for scripting ftp and telnet workflows, so I guess you could use it for that too.

Installation

API

Note: all methods return $this for fluent chaining.

Spawn a new instance of expect for the given command. You can optionally specify a working directory and a PSR compatible logger to use.

Expect the given text to show up on stdout. Expect will block and keep checking the stdout buffer until your expectation shows up or the timeout is reached, whichever comes first.

You can use shell wildcards to match parts of output.

Send the given text on stdin. A newline is added to each string to simulate pressing enter. If you want to just send enter you can do send(PHP_EOL)

Examples

Simple Example

This example opens cat without any arguments, which will simply echo back everything you type to it.

Npm init

This example demonstrates creating a new package.json with npm. Globs are used to match the expectations so we don't need to type them exactly.

Logging

You will probably need logging to figure out what is happening. Expect accepts a PSR compatible logger during instantiation. You can use the Yuloh\Expect\ConsoleLogger for readable output while writing scripts or debugging. For example, instantiating Expect like this:

...would output this to the terminal:

Exceptions

There are a couple of things that can go wrong while running your process:

If the process fails to start, a RuntimeException is thrown. The Yuloh\Expect\Exceptions namespace contains exceptions for the other three scenarios. All of the exceptions extend Yuloh\Expect\FailedExpectationException so you can just catch that one if you like.

Buffering

Some programs like Composer buffer the output so Expect won't work unless you unbuffer the output. The easiest way to do this is probably using script. Modify your command to pipe through script like this:

Then you can pass that in to Expect:

You will probably need to modify expectations when using script, since what you type will show up in stdout too.

Testing


All versions of expect with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
psr/log 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 yuloh/expect contains the following files

Loading the files please wait ....