{"id":17989477,"url":"https://github.com/evilfreelancer/openvpn-php","last_synced_at":"2025-10-05T01:48:00.112Z","repository":{"id":62503219,"uuid":"119587806","full_name":"EvilFreelancer/openvpn-php","owner":"EvilFreelancer","description":"OpenVPN config generator/importer written on PHP","archived":false,"fork":false,"pushed_at":"2020-07-20T03:07:02.000Z","size":96,"stargazers_count":30,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-06T05:35:31.543Z","etag":null,"topics":["config","generator","laravel","oop","openvpn","openvpn-php","package","php7"],"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/EvilFreelancer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"efreelancer"}},"created_at":"2018-01-30T20:04:01.000Z","updated_at":"2025-09-05T04:44:47.000Z","dependencies_parsed_at":"2022-11-02T10:15:58.581Z","dependency_job_id":null,"html_url":"https://github.com/EvilFreelancer/openvpn-php","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/EvilFreelancer/openvpn-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fopenvpn-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fopenvpn-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fopenvpn-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fopenvpn-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvilFreelancer","download_url":"https://codeload.github.com/EvilFreelancer/openvpn-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fopenvpn-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274314810,"owners_count":25262695,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"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":["config","generator","laravel","oop","openvpn","openvpn-php","package","php7"],"created_at":"2024-10-29T19:14:46.802Z","updated_at":"2025-10-05T01:47:55.067Z","avatar_url":"https://github.com/EvilFreelancer.png","language":"PHP","readme":"[![Latest Stable Version](https://poser.pugx.org/evilfreelancer/openvpn-php/v/stable)](https://packagist.org/packages/evilfreelancer/openvpn-php)\n[![Build Status](https://travis-ci.org/evilfreelancer/openvpn-php.svg?branch=master)](https://travis-ci.org/EvilFreelancer/openvpn-php)\n[![Total Downloads](https://poser.pugx.org/evilfreelancer/openvpn-php/downloads)](https://packagist.org/packages/evilfreelancer/openvpn-php)\n[![License](https://poser.pugx.org/evilfreelancer/openvpn-php/license)](https://packagist.org/packages/evilfreelancer/openvpn-php)\n[![Code Climate](https://codeclimate.com/github/EvilFreelancer/openvpn-php/badges/gpa.svg)](https://codeclimate.com/github/EvilFreelancer/openvpn-php)\n[![Code Coverage](https://scrutinizer-ci.com/g/EvilFreelancer/openvpn-php/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/EvilFreelancer/openvpn-php/?branch=master)\n[![Scrutinizer CQ](https://scrutinizer-ci.com/g/EvilFreelancer/openvpn-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/EvilFreelancer/openvpn-php/)\n\n# OpenVPN config manager\n\nOpenVPN configuration manager written on PHP.\n\n    composer require evilfreelancer/openvpn-php\n\nBy the way, OpenVPN library support Laravel framework, details [here](#laravel-framework-support).\n\n## How to use\n\nIt's very simple, you need to set the required parameters, then\ngenerate the config and voila, everything is done.\n\nMore examples [here](examples).\n\n### Write new config in OOP style\n\n```php\nrequire_once __DIR__ . '/../vendor/autoload.php';\n\n// Config object\n$config = new \\OpenVPN\\Config();\n\n// Set server options\n$config-\u003edev                  = 'tun';\n$config-\u003eproto                = 'tcp';\n$config-\u003eport                 = 1194;\n$config-\u003eresolvRetry          = 'infinite';\n$config-\u003ecipher               = 'AES-256-CBC';\n$config-\u003eredirectGateway      = true;\n$config-\u003eserver               = '10.8.0.0 255.255.255.0';\n$config-\u003ekeepalive            = '10 120';\n$config-\u003erenegSec             = 18000;\n$config-\u003euser                 = 'nobody';\n$config-\u003egroup                = 'nogroup';\n$config-\u003epersistKey           = true;\n$config-\u003epersistTun           = true;\n$config-\u003ecompLzo              = true;\n$config-\u003everb                 = 3;\n$config-\u003emute                 = 20;\n$config-\u003estatus               = '/var/log/openvpn/status.log';\n$config-\u003elogAppend            = '/var/log/openvpn/openvpn.log';\n$config-\u003eclientConfigDir      = 'ccd';\n$config-\u003escriptSecurity       = 3;\n$config-\u003eusernameAsCommonName = true;\n$config-\u003everifyClientCert     = 'none';\n\n// Set routes which will be used by server after starting\n$config-\u003esetRoutes([\n    '10.1.1.0 255.255.255.0',\n    '10.1.2.0 255.255.255.0',\n    '10.1.3.0 255.255.255.0',\n]);\n\n// Set additional certificates of server\n$config-\u003esetCerts([\n    'ca'   =\u003e '/etc/openvpn/keys/ca.crt',\n    'cert' =\u003e '/etc/openvpn/keys/issued/server.crt',\n]); // You can embed certificates into config by adding true as second parameter of setCerts method\n\n// Another way for adding certificates\n$config\n    -\u003esetCert('key', '/etc/openvpn/keys/private/server.key')\n    -\u003esetCert('dh', '/etc/openvpn/keys/dh.pem');\n\n// Set pushes which will be passed to client\n$config-\u003esetPushes([\n    // Additional routes, which clients will see\n    'route 10.1.2.0 255.255.255.0',\n    'route 10.1.3.0 255.255.255.0',\n    'route 10.1.4.0 255.255.255.0',\n\n    // Replace default gateway, all client's traffic will be routed via VPN\n    'redirect-gateway def1',\n\n    // Prepend additional DNS addresses    \n    'dhcp-option DNS 8.8.8.8', \n    'dhcp-option DNS 8.8.4.4',\n]);\n\n// Generate config by options\necho $config-\u003egenerate();\n```\n\n### Import existing OpenVPN config\n\nFor example, you have `server.conf`, to import this file you need create\n`\\OpenVPN\\Import` object and specify a name of your config file.\n\n```php\n\u003c?php\nrequire_once __DIR__ . '/../vendor/autoload.php';\n\n// Import OpenVPN config file\n$import = new \\OpenVPN\\Import('server.conf');\n\n// or (classic way)\n$import = new \\OpenVPN\\Import();\n$import-\u003eread('server.conf');\n\n// Parse configuration and return \"\\OpenVPN\\Config\" object\n$config = $import-\u003eparse();\n```\n\nIn `$config` variable will be `\\OpenVPN\\Config` object.\n\n### Client config example\n\nFor making client configuration you need just add required parameters\nand generate the config:\n\n```php\n\u003c?php\nrequire_once __DIR__ . '/../vendor/autoload.php';\n\n// Config object\n$config = new \\OpenVPN\\Config();\n\n// Set client options\n$config-\u003eclient();\n$config-\u003edev             = 'tun';\n$config-\u003eproto           = 'tcp';\n$config-\u003eresolvRetry     = 'infinite';\n$config-\u003ecipher          = 'AES-256-CB';\n$config-\u003eredirectGateway = true;\n$config-\u003ekeyDirection    = 1;\n$config-\u003eremoteCertTls   = 'server';\n$config-\u003eauthUserPass    = true;\n$config-\u003eauthNocache     = true;\n$config-\u003enobind          = true;\n$config-\u003epersistKey      = true;\n$config-\u003epersistTun      = true;\n$config-\u003ecompLzo         = true;\n$config-\u003everb            = 3;\n$config-\u003ehttpProxy       = 'proxy-http.example.com 3128';\n\n// Set multiple remote servers\n$config-\u003esetRemotes([\n    'vpn1.example.com 1194',\n    'vpn2.example.com 11194'\n]);\n\n// Set single remote\n$config-\u003esetRemote('vpn1.example.com 1194');\n\n// Or set remote server as parameter of object\n$config-\u003eremote = 'vpn.example.com 1194';\n\n// Set additional certificates of client\n$config-\u003esetCerts([\n    'ca'   =\u003e '/etc/openvpn/keys/ca.crt',\n    'cert' =\u003e '/etc/openvpn/keys/issued/client1.crt',\n    'key'  =\u003e '/etc/openvpn/keys/private/client1.key',\n], true); // true - mean embed certificates into config, false by default\n\n// Generate config by options\necho $config-\u003egenerate();\n```\n\n### Downloadable config\n\nJust a simple usage example:\n\n```php\nheader('Content-Type:text/plain');\nheader('Content-Disposition: attachment; filename=client.ovpn');\nheader('Pragma: no-cache');\nheader('Expires: 0');\n\necho $config-\u003egenerate();\ndie();\n```\n\n## Laravel framework support\n\nThis library is optimized for usage as normal Laravel package, all functional is available via `\\OpenVPN` facade,\nfor access to (for example) client object you need:\n\n```php\n// Config og client object\n$config = \\OpenVPN::client([\n    'dev'              =\u003e 'tun',\n    'proto'            =\u003e 'tcp',\n    'resolv-retry'     =\u003e 'infinite',\n    'cipher'           =\u003e 'AES-256-CB',\n    'redirect-gateway' =\u003e true,\n    'key-direction'    =\u003e 1,\n    'remote-cert-tls'  =\u003e 'server',\n    'auth-user-pass'   =\u003e true,\n    'auth-nocache'     =\u003e true,\n    'persist-key'      =\u003e true,\n    'persist-tun'      =\u003e true,\n    'comp-lzo'         =\u003e true,\n    'verb'             =\u003e 3,\n]);\n\n// Another way for change values\n$config-\u003eset('verb', 3);\n$config-\u003eset('nobind');\n\n// Yet another way for change values via magic methods\n$config-\u003eremote    = 'vpn.example.com 1194';\n$config-\u003ehttpProxy = 'proxy-http.example.com 3128';\n\n// Set multiple remote servers\n$config-\u003esetRemotes([\n    'vpn1.example.com 1194',\n    'vpn2.example.com 11194'\n]);\n\n// Set additional certificates of client\n$config-\u003esetCerts([\n    'ca'   =\u003e '/etc/openvpn/keys/ca.crt',\n    'cert' =\u003e '/etc/openvpn/keys/issued/client1.crt',\n    'key'  =\u003e '/etc/openvpn/keys/private/client1.key',\n], true); // true mean embed certificates into config, false by default\n\n// Generate config by options\necho $config-\u003egenerate();\n```\n\nIt will read `openvpn-client.php` configuration from `config` folder (if it was published of course), then merge your parameters to this\narray and in results you will see the `\\OpenVPN\\Config` object.\n\n### List of available methods\n\n* `\\OpenVPN::server(array $parameters = [])` - Will return `\\OpenVPN\\Config` object with settings loaded from `openvpn-server.php`\n* `\\OpenVPN::client(array $parameters = [])` - Will return `\\OpenVPN\\Config` object with settings loaded from `openvpn-client.php`\n* `\\OpenVPN::importer(string $filename = null, bool $isContent = false)` - Will return `\\OpenVPN\\Import` object, with help of this object\nyou may read OpenVPN configuration of your server or client\n* `\\OpenVPN::generator(\\OpenVPN\\Config $config)` - Will return `\\OpenVPN\\Generator` object with `-\u003egenerate()` method, which may used\nfor render OpenVPN configuration by parameters from Config object \n\n### Installation\n\nThe package's service provider will automatically register its service provider.\n\nPublish the `openvpn-server.php` and `openvpn-client.php` configuration files:\n\n```sh\nphp artisan vendor:publish --provider=\"OpenVPN\\Laravel\\ServiceProvider\"\n```\n\n## Testing\n\nBefore you begin need to install `dev` dependencies\n\n```shell script\ncomposer install --dev\n```\n\nThen run tests\n\n```shell script\ncomposer test\n\n# which same as\ncomposer test:lint\ncomposer test:unit\n```\n\nor\n\n```shell script\n./vendor/bin/phpunit\n```\n\n## Links\n\n* [OpenVPN parameters](https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html) - Full list of available parameters what can be used\n* [Laravel VPN Admin](https://github.com/Laravel-VPN-Admin) - Web interface for your VPN server\n* [OpenVPN Admin](https://github.com/Chocobozzz/OpenVPN-Admin) - Web interface for your OpenVPN server\n* [Docker for OpenVPN Admin](https://github.com/EvilFreelancer/docker-openvpn-admin) - Dockerized web panel together with OpenVPN\n* [PHP OpenVPN](https://github.com/paranic/openvpn) - Yet another library for generating OpenVPN config files\n","funding_links":["https://patreon.com/efreelancer"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilfreelancer%2Fopenvpn-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilfreelancer%2Fopenvpn-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilfreelancer%2Fopenvpn-php/lists"}