Download the PHP package seblhaire/autocompleter without Composer

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

Autocompleter

By Sébastien L'haire

A Laravel library with Javascript JQuery script to add input with auto-completer to a form.

It uses:

Demo site available here.

Installation

  1. composer require seblhaire/autocompleter
  2. Composer will automatically link the package with Laravel. But you still can explicitely add provider and facade to your config/app.php:

  3. Publish package (optionally).

  4. For Javascript and stylesheets, see next section.

Javascript ans stylesheets

On a webpage, every JS library and CSS stylesheets can be linked separately. If you choose this classical way, first dowload and install above mentionned libraries. Then publish package files as explained above and put following tags in your template:

But websites often use many libraries and stylesheets and browser must download many files before the site can be rendered properly. Modern websites come with a single compressed Javascript file which concatenates necessary scripts; same principle for stylesheets. With Laravel you can use Laravel Mix to compile files.

Use NPM package manager : npm install bootstrap jquery

Then your js source file should be something like this:

For your stylesheet:

Configuration file

Autocompleter library is customizable. Default values can be changed, either in configuration file, or by passing options in Facade function (see next section). If you want to modify default configuration file, publish package files and access to config/autocompleter.php.

Usage

Autocompleter package comes with a simple Facade.

AutocompleterHelper::init

Inits an autocompleter object that can be passed to the view.

AutocompleterHelper::init($inputid, $labeltext, $url, $options) where:

To summarize, in your controller insert:

In your blade template, insert following at the place you want the autocompleter to appear:

{!! $ac !!} or {!! $ac->output() !!}

Output methods

output()

This method output() prints tags and outputs autocompleter initalisation script. It uses the above methods, that can be used to integrate autocompleter in other widgets, or to organize code as you wish.

printDiv()

This method prints the main <div>. It uses methods printInsideDiv() and printHelp()

printInsideDiv()

Prints <div> that contains label, form input and result list. That container is necessary to define a fixed width. It uses methods printLabel(), printInput() and printResultDiv().

printHelp()

Prints help text below input line.

printResultDiv()

Prints results container which contains the proposal list.

printLabel()

Prints autocompleter label.

printInput()

Prints autocompleter input field.

printJsInit()

Prints JavaScript code to init autocompleter.

Utils::highlite($string, $search, $classes)

Takes a string, search a susbtring in it and highlites the corresponding chunk(s)

Utils::highlite($string, $search, $classes) : string

where:

The function returns the highlighted string.

Search function

You must build a simple method in a controller that will be called to update result lists. Here are a few requirements:

  1. your route has to accept the POST method;
  2. two parameters only are built in the autocompleter object:
    • 'search' contains the current string in input;
    • 'maxresults' is an integer for the maximum of results acceptable for the autocompleter. We provide a request model AutocompleterRequest to perform form validation.
      1. the method must return a json object with a single field named 'res' which contains an array of result lines.
      2. result lines are an array which must contain at least the following fields:
    • a field whose key corresponds to the config value id_field (cf. above) (config('autocompleter.highliteclasses'));
    • a field whose key corresponds to the config value list_field, which contains the text for the autocompleter result list. If id_included has value true in config, the autocompleter object will add automatically the id_field value. In this field you can use the above mentioned function Utils::highlite. To summarize here is a complete example:

Translation keys

Laravel loads config files very early in process. Therefore config files cannot contain __('translation.key'). In order to solve this issue, we made an helper either to print directly strings or to send translation key to translation helper. Translation keys can be delimited by character # . Ex: "#autocompleter::messages.autocompleterhelp#". Original translations are stored under vendor/seblhaire/autocompleter/resources/lang. If you publish package files, you can find translations in resources/lang/vendor/autocompleter/.

Feel free to translate keys in your own language and either to send it to the author or to do a merge request on GitHub.

Questions? Contributions?

Feel free to send feature requests or merge request to the author or simply to ask questions.


All versions of autocompleter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
illuminate/http Version ^11.0
danielstjules/stringy Version ^3.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 seblhaire/autocompleter contains the following files

Loading the files please wait ....