Download the PHP package kudashevs/laravel-share-buttons without Composer

On this page you can find all versions of the php package kudashevs/laravel-share-buttons. 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 laravel-share-buttons

Laravel Share Buttons test workflow

This Laravel package provides the possibility to generate share links (social media share buttons) for your site in a flexible and convenient way within seconds. The package was originated from the Laravel Share.

Available services

Installation

You can install the package via composer:

If you don't use auto-discovery just add a ShareButtonsServiceProvider to the config/app.php

By default, the ShareButtons class instance is bound to the sharebuttons alias. You might want to add a ShareButtonsFacade::class to the aliases, too.

Don't forget to publish the configuration file and assets. The configuration file is required.

In case of a major change, it is recommended to back up your config file and republish a new one from scratch.

You can customize the process of publishing assets. If you want to limit the type of assets, you can use the --tag option with one of the following tags: config, js (all js files), vanilla, jquery, css.

Assets

By default, this package relies on the Font Awesome icons. The buttons' interactivity is implemented in two different ways (via Vanilla JS and jQuery). However, you can use any custom fonts, icons, or JavaScript.

Font Awesome and default styles

To enable Font Awesome icons, use the code sample below in your template. For further information on how to use Font Awesome, please read the introduction.

To enable the default styles, you should publish the assets tagged as css (the command will create a resources/css/share-buttons.css file). After publishing, you can copy this file to your public/css folder and use it directly by applying the code sample below. Or you can integrate the css file into your assets compilation flow.

JavaScript

To enable interaction on social media buttons with JavaScript, you should publish the assets tagged as vanilla (the command will create a resources/js/share-buttons.js file). After publishing, you can copy this file to your public/js folder and use it directly by applying the code sample below. Or you can integrate this file into your assets compilation flow.

jQuery

To enable interaction on social media buttons with jQuery, you should publish the assets tagged as jquery (the command will create a resources/js/share-buttons.jquery.js file). After publishing, you can copy this file to your public/js folder and use it directly by applying the code sample below. Or you can integrate this file into your assets compilation flow.

Usage

Let's take a look at a short usage example (you can find a detailed usage example in the corresponding section).

The code above will result into the following HTML code:

Fluent interface

The ShareButtons instance provides a fluent interface. The fluent interface is a pattern based on method chaining. To start a method chaining you just need to use one of the methods listed below (the starting point).

Add buttons

To generate a single social media button, you just need to add one of the following methods to the method chaining. Each method accepts an array of options (more information about these options in the local options section).

These methods are a part of the fluent interface. Therefore, to create multiple social media share buttons you just need to chain them.

Getting share buttons

You can use a ShareButtons instance as a string or cast it to a string to get ready-to-use HTML code. However, this is not the best way. If you want to be clear in your intentions, use one of the methods that return generated HTML code. These methods are:

Getting raw links

Sometimes, you may only want the raw links without any HTML. In such a case, just use the getRawLinks method.

Parameters

There is the possibility of providing different options to style and decorate the resulting HTML code at different levels.

Global options

Every time a chaining method is called, it accepts several arguments, including a page URL (depending on the method), a page title, and an array of options. These options are global because they change the representation of all share buttons. These options are:

Local options

Any of the share button methods, that generates a button, accepts several arguments. These options are local because they will be applied to a specific element only. The local options have a higher priority. Therefore, they will overwrite the global options if there is any overlap. At the moment, the package supports the following local options:

Configuration

The configuration settings are located in the config/share-buttons.php file.

Representation section

This section contains settings related to the "container" in which the social media buttons will be displayed.

Share buttons section

Each social media share button has its own individual configuration settings.

note: a text value might contain a url element, which will be replaced by the page url while processing.

Templates section

Each share button has a corresponding link template. A template contains several elements that will be substituted with data from different arguments and options. The format of these elements depends on the templater setting. By default, these elements are:

Templaters section

For processing different templates and substitute elements in them, the package uses templaters (template engines). By default, these options are optional (if no value provided, the default templater will be used).

A detailed usage example

To summarize all of the information from above, let's take a look at a real-life example. We begin with one of the methods that start the fluent interface, and we provide some global options. Then, we add some specific methods that generate social media share buttons. At this step, we can provide any local options, as it is done in the linkedin() method. Finally, we finish the fluent interface chain with one of the methods that return the resulting HTML code.

The code above will result into the following HTML code:

Testing

If you want to make sure that everything works as expected, you can run unit tests provided with the package.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see the License file for more information.


All versions of laravel-share-buttons with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
symfony/polyfill-php80 Version ^1.31
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 kudashevs/laravel-share-buttons contains the following files

Loading the files please wait ....