Download the PHP package dpeuscher/alfred-symfony-tools without Composer

On this page you can find all versions of the php package dpeuscher/alfred-symfony-tools. 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 alfred-symfony-tools

Build Status codecov FOSSA Status

alfred-symfony-tools

Toolkit for integrating Alfred workflows with Symfony4 Frameworks Commands

This toolkit helps if you want to use the Symfony Command-Structure with Alfred workflows. You can easily add ways to autocomplete parameters without thinking too much about the idea that Alfred workflows will start a new process everytime you type something. Also there is a Command that you can extend from to allow you setting .env-Parameters via Alfred.

Autocomplete Lists

To provide the user of your Alfred workflow with an easy way to navigate through his options, you have to provide a list of allowed values for your arguments. With that the user can easily walk through all options with the Alfred interface.

To create a Command that is capable of this, you need to extend from either or . You have then the ability to either define the allowed values while defining the argument in the -method (good for static arguments, whose values are hardcoded) or later in the -method of the Command.

Hard coded argument-lists

You can see that it is possible to use numeric or associative option-lists. If you use numeric lists (arg1), the selector willbe defined automatically by the first combination of words that identify your option. For associative lists (arg2) the keys will be used as identifier. You can allow to add selections that are not in the list by setting the -parameter to true (arg3). Also it is possible that you mix autocomplete-arguments with general ones (arg4, arg5).

Dynamically loaded argument-lists

Since the container is not available in the -method, you might want to add options in the -method from parameters that are set in the config or .env file. You can to that with the -method that also supports the -parameter.

Execution operations

Now you want to be able to handle different inputs differently. There are predefined input-handlers for the autocomplete arguments, but you can easily override them with the -method. Just define for which set of arguments you want to define a handler and define it. The handler itself can be a closure or a method within the Command-class. It gets an array of the given variables and possible autocomplete-values and the result of the generic result as a parameter so you can get started pretty quick in changing the result. If you don't return something it will default to the (possibly aligned) genericResult-entry from the arguments-array.

To set the titles of the options of arg3 to have a leading uppercase letter when you had selected option1 as arg1 you could do something like this:

The order of the parameters matters. in the upper example will never match!

The -class is only a representation for the format of the Alfred workflow json definition. It supports the following method:

To understand their meaning please look into the Alfred documentation. As an addition, if you provide a url as an icon, will copy it to your tmp folder (that you can change in the constructor), formats it and uses it, since Alfred itself can only handle local images.

ConfigureCommand

To use the ConfigureCommand to write data into your .env-file you have to extend it in your commands-folder to make it dispatchable. You then have to define which Variables you want to be able to change via Alfred and define them in your configuration at the key . It should be a numeric array, that has the names of the variables as values. If you want to define an array, add behind its name.

You can then set these values if you call the route in your application.

DotEnvEditor

To use the ConfigureCommand you have to create a special config, that has be to named dotenveditor.php and should be in your config/-folder. If you want to set it somewhere else you can do so by setting the config parameter configDotEnvFileConfiguration to the path where it can be found. the file needs to return an array with at least the key that links to your .env-file. You can optionally provide a for backups. An example file for the default configuration would be:

config/dotenveditor.php:

Alfred Workflow

alfred.php

To properly work, you need a special alfred-bin file. It should not have the shebang-line of the bin/console script in it, because that would break the valid json-output. Therefor the easiest way would be to copy the bin/console to bin/alfred.php. You can also use the provided alfred.php in the example-folder of this repository.

To have a proper escaping, you should add these lines underneath the use-statements of the console-file (the alfred.php in the examples folder has it already):

Creating the workflow

You create a new Alfred workflow by clicking on the "+" in the bottom bar and select "Blank Workflow". After that, select your workflow and right click into the empty space, click on "Input" and select "Script Filter". Double-click the "Script Filter" item on the page and define a placeholder. Configure the placeholder-stuff as you like. Use the following script to have the dispatching working:

You have to select "/usr/bin/php" as Language, "with input as {query}", tick "Double Quotes", "Backslashes" and "Dollars" in the "Escaping"-Selection on the bottom.

Replace the "command" in the script and keyword section by the command you want to have

Tips

Environment variables

The output commands can use variables, that you pass in the -method of the -Class to work with it. You can access it in the command as a protected parameter :

In the connected script, you can access it by calling environment variables. Here are a few ways to access:

Config command

Activate "Argument Optional" instead of "Argument Required". The script for the config looks like this:

It is connected to a "Run Script" item with the following script:

The rest of the settings of the "Run Script" should look like the "Script Input" item.

Example

Find a proof-of-concept here: dpeuscher/alfred-movie-rating

License

FOSSA Status


All versions of alfred-symfony-tools with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
ext-ctype Version *
ext-iconv Version *
symfony/framework-bundle Version ^4.0
joetannenbaum/alfred-workflow Version ^0.1.1
symfony/console Version ^4.1
monolog/monolog Version ^1.23
makbari/dot-env-editor Version ^0.1.4
symfony/yaml Version ^4.1
symfony/dotenv Version ^4.1
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 dpeuscher/alfred-symfony-tools contains the following files

Loading the files please wait ....