{"id":15029152,"url":"https://github.com/taylornetwork/linkify","last_synced_at":"2026-04-06T00:03:10.228Z","repository":{"id":57065511,"uuid":"154406348","full_name":"taylornetwork/linkify","owner":"taylornetwork","description":"Painlessly convert links in text to HTML or Markdown","archived":false,"fork":false,"pushed_at":"2019-06-04T00:34:02.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T21:48:42.633Z","etag":null,"topics":["convert-links","html","laravel","laravel-package","linkify","markdown","php","php7","user-input"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taylornetwork.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-23T22:45:55.000Z","updated_at":"2022-02-12T08:57:21.000Z","dependencies_parsed_at":"2022-08-24T07:50:42.437Z","dependency_job_id":null,"html_url":"https://github.com/taylornetwork/linkify","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylornetwork%2Flinkify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylornetwork%2Flinkify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylornetwork%2Flinkify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylornetwork%2Flinkify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taylornetwork","download_url":"https://codeload.github.com/taylornetwork/linkify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243338553,"owners_count":20275528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["convert-links","html","laravel","laravel-package","linkify","markdown","php","php7","user-input"],"created_at":"2024-09-24T20:09:50.512Z","updated_at":"2025-12-30T00:24:13.378Z","avatar_url":"https://github.com/taylornetwork.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linkify\n\nA package to convert all links in a string to Markdown, HTML, or your own custom format.\n\nPainlessly Convert:\n\n```php\n'This text has a link https://github.com/taylornetwork/linkify and also another one https://google.com'\n```\n\nTo:\n\n```php\n'This text has a link [github.com](https://github.com/taylornetwork/linkify) and also another one [google.com](https://google.com)'\n \n// OR \n \n'This text has a link \u003ca href=\"https://github.com/taylornetwork/linkify\"\u003egithub.com\u003c/a\u003e and also another one \u003ca href=\"https://google.com\"\u003egoogle.com\u003c/a\u003e'\n```\n\n## Install\n\nVia Composer\n\n```bash\n$ composer require taylornetwork/linkify\n```\n\n## Usage\n\nSee [Config Options](#config)\n\n### Linkify Class\n\n**Basic Usage**\n\n```php\nuse TaylorNetwork\\Linkify\\Linkify;\n\n$text = 'This has a link. https://google.com';\n\n$linkify = new Linkify;\n$linkify-\u003eparse($text);\n```\n\nReturns\n\n```\n'This has a link. [google.com](https://google.com)'\n```\n\n**Basic Usage - Static Call**\n\n```php\nuse TaylorNetwork\\Linkify\\Linkify;\n\n$text = 'This has a link. https://google.com';\n\nLinkify::instance()-\u003eparse($text);\n```\n\nReturns\n\n```\n'This has a link. [google.com](https://google.com)'\n```\n\n**Override Config**\n\n```php\nuse TaylorNetwork\\Linkify\\Linkify;\n\n$text = 'This has a link. https://google.com';\n\n$linkify = new Linkify;\n$linkify-\u003esetConfig('convertTo', Linkify::ConvertHTML);\n$linkify-\u003eparse($text);\n```\n\nReturns\n\n```\n'This has a link. \u003ca href=\"https://google.com\"\u003egoogle.com\u003c/a\u003e'\n```\n\n**Override Config - Static, One Line**\n\n```php\nuse TaylorNetwork\\Linkify\\Linkify;\n\n$text = 'This has a link. https://google.com';\n\nLinkify::instance()-\u003esetConfig('convertTo', Linkify::ConvertHTML)-\u003eparse($text);\n```\n\nReturns\n\n```\n'This has a link. \u003ca href=\"https://google.com\"\u003egoogle.com\u003c/a\u003e'\n```\n\n---\n\n### Makes Links Trait\n\nThe `MakesLinks` trait will allow you to access the parser with a `linkify($text)` method on your class.\n\n**Basic Usage**\n\n```php\nuse TaylorNetwork\\Linkify\\MakesLinks;\n\nclass DummyClass\n{\n\tuse MakesLinks;\n\t\n\tprotected $text = 'This has a link. https://google.com';\n\t\n\tpublic function getParsedText()\n\t{\n\t\treturn $this-\u003elinkify($this-\u003etext);\n\t}\n}\n```\n\n`getParsedText()` returns\n\n```\n'This has a link. [google.com](https://google.com)'\n```\n\n**Override Config**\n\n```php\nuse TaylorNetwork\\Linkify\\MakesLinks;\nuse TaylorNetwork\\Linkify\\Linkify;\n\nclass DummyClass\n{\n\tuse MakesLinks;\n\t\n\tprotected $text = 'This has a link. https://google.com';\n\t\n\tpublic function getParsedText()\n\t{\n\t\treturn $this-\u003elinkify($this-\u003etext);\n\t}\n\t\n\tpublic function linkifyConfig(\u0026$linkify)\n\t{\n\t\t$linkify-\u003esetConfig('convertTo', Linkify::ConvertHTML);\n\t\t$linkify-\u003esetConfig('linkAttributes', [\n\t\t\t'class' =\u003e 'btn-link'\n\t\t]);\n\t}\n}\n```\n\n`getParsedText()` returns\n\n```\n'This has a link. \u003ca class=\"btn-link\" href=\"https://google.com\"\u003egoogle.com\u003c/a\u003e'\n```\n\n**With Custom Format**\n\n```php\nuse TaylorNetwork\\Linkify\\MakesLinks;\nuse TaylorNetwork\\Linkify\\Linkify;\n\nclass DummyClass\n{\n\tuse MakesLinks;\n\t\n\tprotected $text = 'This has a link. https://google.com';\n\t\n\tpublic function getParsedText()\n\t{\n\t\treturn $this-\u003elinkify($this-\u003etext);\n\t}\n\t\n\tpublic function linkifyConfig(\u0026$linkify)\n\t{\n\t\t$linkify-\u003esetConfig('convertTo', Linkify::ConvertCustom);\n\t}\n\t\n\tpublic function linkifyCustomParse(string $caption, string $url) \n\t{\n\t\treturn '=\u003e' . $caption . '\u003c=#' . $url . '#';\n\t}\n}\n```\n\n`getParsedText()` returns\n\n```\n'This has a link. =\u003egoogle.com\u003c=#https://google.com#'\n```\n\n\n## Config\n\nPublish the config using the artisan command.\n\n```bash\n$ php artisan vendor:publish --provider=\"TaylorNetwork\\Linkify\\LinkifyServiceProvider\"\n```\n\nWill publish the config file to `config/linkify.php`\n\n---\n\n#### Link Format\n\nYou can change the default link format by changing the `convertTo` setting in `config/linkify.php`\n\n```php\n'convertTo' =\u003e Linkify::ConvertMarkdown, // Converts to markdown links\n// OR\n'convertTo' =\u003e Linkify::ConvertHTML,     // Converts to \u003ca\u003e links\n// OR\n'convertTo' =\u003e Linkify::ConvertCustom,   // Your own custom callback\n```\n---\n#### Link Attributes (HTML Only)\n\nYou can add any HTML link attributes you want to include in the `\u003ca\u003e` tag when generating a link (Don't use `href`). \n\nAdd the key and value to the `linkAttributes` array.\n\n```php\n'linkAttributes' =\u003e [\n\t'target' =\u003e '_blank',\n\t'class' =\u003e 'btn-link',\n],\n```\n\nWould generate links:\n```\n\u003ca target=\"_blank\" class=\"btn-link\" href=\"$url\"\u003e$caption\u003c/a\u003e\n``` \nWhere `$caption` and `$url` would be replaced automatically.\n\n*Note: attributes are added in the order from the array and this only runs if using the `Linkify::ConvertHTML` setting in `convertTo`*\n\n---\n\n#### Only format non-formatted links\n\nThe `checkForExistingFormatting` setting should be set to `true` if you want to only convert links that don't have existing formatting (default).\n\nFor example:\n\n```php\n// Link is already formatted, by user, or another package, etc.\n$text = 'Link: [link](https://google.com)';\n\nLinkify::instance()-\u003eparse($text);\n\n// Returns\n\n// If 'checkForExistingFormatting' is true\n'Link: [link](https://google.com)'\n\n// If 'checkForExistingFormatting' is false\n'Link: [link]([google.com](https://google.com))'\n```\n---\n#### Custom Formatting\n\n**You can define a custom formatter in the config file, but prefer that you use the `MakeLinks` trait.**\n\n[See Makes Links Trait](#makes-links-trait)\n\n```php\n'customCallback' =\u003e function ($caption, $url) {\n\treturn '{' . $caption . '}#' . $url . '#';\n},\n```\n\nIf `'convertTo' =\u003e Linkify::ConvertCustom` the `$caption` and `$url` will be passed to the callback.\n\nThis would return: `'{google.com}#https://google.com#'`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylornetwork%2Flinkify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaylornetwork%2Flinkify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylornetwork%2Flinkify/lists"}