{"id":19543868,"url":"https://github.com/benjpaddock/laravel-share-buttons","last_synced_at":"2026-05-14T12:36:17.995Z","repository":{"id":254330996,"uuid":"846200848","full_name":"benjpaddock/laravel-share-buttons","owner":"benjpaddock","description":"A laravel share buttons package.","archived":false,"fork":false,"pushed_at":"2024-08-22T18:48:08.000Z","size":1108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-21T22:39:16.222Z","etag":null,"topics":["laravel","share-buttons","social-media-buttons"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benjpaddock.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-22T18:11:24.000Z","updated_at":"2024-08-22T18:49:56.000Z","dependencies_parsed_at":"2024-08-22T21:14:23.193Z","dependency_job_id":null,"html_url":"https://github.com/benjpaddock/laravel-share-buttons","commit_stats":null,"previous_names":["benjpaddock/laravel-share-buttons"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/benjpaddock/laravel-share-buttons","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjpaddock%2Flaravel-share-buttons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjpaddock%2Flaravel-share-buttons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjpaddock%2Flaravel-share-buttons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjpaddock%2Flaravel-share-buttons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benjpaddock","download_url":"https://codeload.github.com/benjpaddock/laravel-share-buttons/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjpaddock%2Flaravel-share-buttons/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33025347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","share-buttons","social-media-buttons"],"created_at":"2024-11-11T03:22:50.634Z","updated_at":"2026-05-14T12:36:17.474Z","avatar_url":"https://github.com/benjpaddock.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Share Buttons ![test workflow](https://github.com/kudashevs/laravel-share-buttons/actions/workflows/run-tests.yml/badge.svg)\n\nThis Laravel package provides the possibility to generate share links (social media share buttons) for your site in\na flexible and convenient way within seconds. The package was originated from the Laravel Share.\n\n[//]: # (@todo don't forget to update these services)\n### Available services\n\n* Facebook\n* X (formerly Twitter)\n* LinkedIn\n* Telegram\n* WhatsApp\n* Reddit\n* Hacker News\n* VKontakte\n* Pinterest\n* Pocket\n* Evernote\n* Skype\n* Xing\n* Copy the link\n* Mail the link\n\n\n## Installation\n\nYou can install the package via composer:\n```bash\ncomposer require kudashevs/laravel-share-buttons\n```\n\nIf you don't use auto-discovery just add a ShareButtonsServiceProvider to the `config/app.php`\n```php\n'providers' =\u003e [\n    Kudashevs\\ShareButtons\\Providers\\ShareButtonsServiceProvider::class,\n],\n```\nBy default, the `ShareButtons` class instance is bound to the `sharebuttons` alias. You might want to add a\n`ShareButtonsFacade::class` to the aliases, too.\n\n\u003ca id=\"publish\"\u003e\u003c/a\u003e**Don't forget** to publish the configuration file and assets. The configuration file is required.\n```bash\nphp artisan vendor:publish --provider=\"Kudashevs\\ShareButtons\\Providers\\ShareButtonsServiceProvider\"\n```\n\u003e In case of a major change, it is recommended to back up your config file and republish a new one from scratch.\n\nYou can customize the process of publishing assets. If you want to limit the type of assets, you can use the `--tag` option\nwith one of the following tags: `config`, `js` (all js files), `vanilla`, `jquery`, `css`.\n\n## Assets\n\nBy default, this package relies on the `Font Awesome` icons. The buttons' interactivity is implemented in two\ndifferent ways (via `Vanilla JS` and `jQuery`). However, you can use any custom fonts, icons, or JavaScript.\n\n### Font Awesome and default styles\n\nTo 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](https://fontawesome.com/docs/web/setup/get-started).\n```html\n\u003clink rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css\"\u003e\n```\n\nTo enable the default styles, you should [publish](#publish) the assets tagged as `css` (the command will create a `resources/css/share-buttons.css` file). After publishing,\nyou 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.\n```html\n\u003clink rel=\"stylesheet\" href=\"{{ asset('css/share-buttons.css') }}\"\u003e\n```\n\n### JavaScript\n\nTo enable interaction on social media buttons with JavaScript, you should [publish](#publish) the assets tagged as `vanilla` (the command will create a `resources/js/share-buttons.js` file).\nAfter 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.\n```html\n\u003cscript src=\"{{ asset('js/share-buttons.js') }}\"\u003e\u003c/script\u003e\n```\n\n### jQuery\n\nTo enable interaction on social media buttons with jQuery, you should [publish](#publish) the assets tagged as `jquery` (the command will create a `resources/js/share-buttons.jquery.js` file).\nAfter 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.\n```html\n\u003cscript src=\"https://code.jquery.com/jquery-3.5.1.slim.min.js\" integrity=\"sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n\u003cscript src=\"{{ asset('js/share-buttons.jquery.js') }}\"\u003e\u003c/script\u003e\n```\n\n\n## Usage\n\nLet's take a look at a short usage example (you can find a detailed usage example in the [corresponding section](#a-detailed-usage-example)).\n```php\nShareButtons::page('https://site.com', 'Page title', [\n        'title' =\u003e 'Page title',\n        'rel' =\u003e 'nofollow noopener noreferrer',\n    ])\n    -\u003efacebook()\n    -\u003elinkedin(['rel' =\u003e 'follow'])\n    -\u003erender();\n```\n\nThe code above will result into the following HTML code:\n```html\n\u003cdiv id=\"social-buttons\"\u003e\n    \u003ca href=\"https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fsite.com\u0026quote=Page+title\" class=\"social-button\" title=\"Page title\" rel=\"nofollow noopener noreferrer\"\u003e\u003cspan class=\"fab fa-facebook-square\"\u003e\u003c/span\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.linkedin.com/sharing/share-offsite?mini=true\u0026url=https%3A%2F%2Fsite.com\u0026title=Page+title\u0026summary=\" class=\"social-button\" title=\"Page title\" rel=\"follow\"\u003e\u003cspan class=\"fab fa-linkedin\"\u003e\u003c/span\u003e\u003c/a\u003e\n\u003c/div\u003e\n```\n\n### Fluent interface\n\nThe `ShareButtons` instance provides a fluent interface. The fluent interface is a pattern based on method chaining.\nTo start a method chaining you just need to use one of the methods listed below (the starting point).\n```\npage($url, $title, $options)              # Creates a chaining with a given URL and a given page title\ncreateForPage($url, $title, $options)     # Does the same (an alias of the page() method)\ncurrentPage($title, $options)             # Creates a chaining with the current page URL and a given page title\ncreateForCurrentPage($title, $options)    # Does the same (an alias of the currentPage() method)\n```\n\n### Add buttons\n\nTo generate a single social media button, you just need to add one of the following methods to the [method chaining](#fluent-interface).\nEach method accepts an array of options (more information about these options in the [local options](#local-options) section).\n\n[//]: # (@todo don't forget to update these methods)\n```\nfacebook($options)      # Generates a Facebook share button\ntwitter($options)       # Generates a Twitter share button\nlinkedin($options)      # Generates a LinkedIn share button\ntelegram($options)      # Generates a Telegram share button\nwhatsapp($options)      # Generates a WhatsApp share button\nreddit($options)        # Generates a Reddit share button\nhackernews($options)    # Generates a Hacker News share button\nvkontakte($options)     # Generates a VKontakte share button\npinterest($options)     # Generates a Pinterest share button\npocket($options)        # Generates a Pocket share button\nevernote($options)      # Generates an Evernote share button\nskype($options)         # Generates a Skype share button\nxing($options)          # Generates a Xing share button\ncopylink($options)      # Generates a copy to the clipboard share button\nmailto($options)        # Generates a send by mail share button\n```\n\nThese methods are a part of the fluent interface. Therefore, to create multiple social media share buttons you just need to chain them.\n\n### Getting share buttons\n\nYou 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.\nIf you want to be clear in your intentions, use one of the methods that return generated HTML code. These methods are:\n```php\nrender()                # Returns a generated share buttons HTML code\ngetShareButtons()       # Does the same (an alias of the render() method)\n```\n\n### Getting raw links\n\nSometimes, you may only want the raw links without any HTML. In such a case, just use the `getRawLinks` method.\n```php\ngetRawLinks()           # Returns an array of generated links\n```\n\n## Parameters\n\nThere is the possibility of providing different options to style and decorate the resulting HTML code at different levels.\n\n### Global options\n\nEvery time a chaining method is called, it accepts several arguments, including a page URL (depending on the method), a page title,\nand an array of options. These options are global because they change the representation of all share buttons. These options are:\n```\n'block_prefix' =\u003e 'tag'          # Sets a share buttons block prefix (default is \u003cdiv id=\"social-buttons\"\u003e)\n'block_suffix' =\u003e 'tag'          # Sets a share buttons block suffix (default is \u003c/div\u003e)\n'element_prefix' =\u003e 'tag'        # Sets an element prefix (default is empty)\n'element_suffix' =\u003e 'tag'        # Sets an element suffix (default is empty)\n'id' =\u003e 'value'                  # Adds an HTML id attribute to the output links\n'class' =\u003e 'value'               # Adds an HTML class attribute to the output links\n'title' =\u003e 'value'               # Adds an HTML title attribute to the output links\n'rel' =\u003e 'value'                 # Adds an HTML rel attribute to the output links\n```\n\n### Local options\n\nAny of the [share button methods](#add-buttons), that generates a button, accepts several arguments. These options are local\nbecause they will be applied to a specific element only. The local options have a **higher priority**. Therefore, they\nwill overwrite the global options if there is any overlap. At the moment, the package supports the following local options:\n```\n'id' =\u003e 'value'                  # Adds an HTML id attribute to the button link\n'class' =\u003e 'value'               # Adds an HTML class attribute to the button link\n'title' =\u003e 'value'               # Adds an HTML title attribute to the button link\n'rel' =\u003e 'value'                 # Adds an HTML rel attribute to the button link\n'summary' =\u003e 'value'             # Adds a summary text to the URL (linkedin button only)\n```\n\n## Configuration\n\nThe configuration settings are located in the `config/share-buttons.php` file.\n\n### Representation section\n\nThis section contains settings related to the \"container\" in which the social media buttons will be displayed.\n```\n'block_prefix' =\u003e 'tag'         # Sets a block prefix (default is \u003cdiv id=\"social-buttons\"\u003e)\n'block_suffix' =\u003e 'tag'         # Sets a block suffix (default is \u003c/div\u003e)\n'element_prefix' =\u003e 'tag'       # Sets an element prefix (default is empty)\n'element_suffix' =\u003e 'tag'       # Sets an element suffix (default is empty)\n```\n\n### Share buttons section\n\nEach social media share button has its own individual configuration settings.\n```\n'url' =\u003e 'value'                # A share button URL template (is used to generate a button's URL)\n'text' =\u003e 'value'               # A default text to be added to the url (is used when the page title is empty)\n'extra' =\u003e [                    # Extra options that are required by some specific buttons\n    'summary' =\u003e 'value'        # A default summary to be added to the url (linkedin only) \n    'raw' =\u003e 'value'            # A boolean defines whether to skip the URL-encoding of the url\n    'hash' =\u003e 'value'           # A boolean defines whether to use a hash instead of the url\n]\n```\n\n### Templates section\n\nEach share button has a corresponding link template. A template contains several elements that will be substituted with\ndata from different arguments and options. The format of these elements depends on the `templater` setting. By default,\nthese elements are:\n```\n:url                            # Will be replaced with a prepared URL\n:id                             # Will be replaced with an id attribute\n:class                          # Will be replaced with a class attribute\n:title                          # Will be replaced with a title attribute\n:rel                            # Will be replaced with a rel attribute\n```\n\n### Templaters section\n\nFor processing different templates and substitute elements in them, the package uses templaters (template engines).\nBy default, these options are optional (if no value provided, the default templater will be used). \n```\n'templater'                     # A template engine for processing link templates\n'url_templater'                 # A template engine for processing share buttons URLs\n```\n\n\n## A detailed usage example\n\nTo summarize all of the information from above, let's take a look at a real-life example. We begin with one of the methods\nthat start the fluent interface, and we provide some global options. Then, we add some specific methods that generate social\nmedia share buttons. At this step, we can provide any local options, as it is done in the `linkedin()` method. Finally,\nwe finish the fluent interface chain with one of the methods that return the resulting HTML code.\n```php\nShareButtons::page('https://site.com', 'Page title', [\n        'block_prefix' =\u003e '\u003cul\u003e',\n        'block_suffix' =\u003e '\u003c/ul\u003e',\n        'element_prefix' =\u003e '\u003cli\u003e',\n        'element_suffix' =\u003e '\u003c/li\u003e',\n        'class' =\u003e 'my-class',\n        'id' =\u003e 'my-id',\n        'title' =\u003e 'my-title',\n        'rel' =\u003e 'nofollow noopener noreferrer',\n    ])\n    -\u003efacebook()\n    -\u003elinkedin(['id' =\u003e 'linked', 'class' =\u003e 'hover', 'rel' =\u003e 'follow', 'summary' =\u003e 'cool summary'])\n    -\u003erender();\n```\n\nThe code above will result into the following HTML code:\n```html\n\u003cul\u003e\n    \u003cli\u003e\u003ca href=\"https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fsite.com\u0026quote=Page+title\" class=\"social-button my-class\" id=\"my-id\" title=\"my-title\" rel=\"nofollow noopener noreferrer\"\u003e\u003cspan class=\"fab fa-facebook-square\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"https://www.linkedin.com/sharing/share-offsite?mini=true\u0026url=https%3A%2F%2Fsite.com\u0026title=Page+title\u0026summary=cool+summary\" class=\"social-button hover\" id=\"linked\" title=\"my-title\" rel=\"follow\"\u003e\u003cspan class=\"fab fa-linkedin\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n```\n\n\n## Testing\n\nIf you want to make sure that everything works as expected, you can run unit tests provided with the package.\n```bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## License\n\nThe MIT License (MIT). Please see the [License file](LICENSE.md) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjpaddock%2Flaravel-share-buttons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjpaddock%2Flaravel-share-buttons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjpaddock%2Flaravel-share-buttons/lists"}