Skip to content
Manage PPPoE connection of TP-Link routers using PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

TP-Link 940/941ND


Control TP-Link 940/941ND router using PHP. This has been tested with TP-Link 940/941ND only but might work with tp link's other routers running similar software.

This package will not work if you have updated your router's firmware to the latest version as all the vulnerabilities have been patched.


composer require nikhil-pandey/tp-link

Or add the following to your composer.json

"nikhil-pandey/tp-link": "^1.0"

###Usage The basic usage is shown below.

// Create new instance
// Accepts 3 parameters. [ Host, Router Username, Router Password ]
// All the parameters are optional, you can set them later
$router = new \NikhilPandey\TpLink\Router($routerHost);
// Setting the Router Username and password if you already haven't
$router->setAuth('router_username', 'router_password');
// Connecting to the WAN connection
// Waits for specified seconds
// Disconnecting the WAN connection
// The current configuration of the router
// The current configuration of the router as an associative array

You can also use static method to instantiate the router and chain methods.

use NikhilPandey\TpLink\Router;

$router = Router::at($routerAddress)
    ->setAuth($loginUsername, $loginPassword)
    ->connect($newWanUsername, $newWanPassword)
    ->disconnect($newWanUsername, $newWanPassword)
$configuration = $router->getConfigAssoc();
if($configuration['status'] == Router.CONNECTED){
    // ...

For more information about the constants and other stuffs, dive into the code :)


Four types of exceptions might occur. InvalidAuthException, UndefinedAuthException and UnknownResponseException, UndefinedHostException. You can catch those and take appropriate actions.

use NikhilPandey\TpLink\Router;
use NikhilPandey\TpLink\Exceptions\InvalidAuthException
// ...
    $router = Router::at($routerAddress)
        ->setAuth($loginUsername, $loginPassword)
        ->connect($newWanUsername, $newWanPassword);
} catch(InvalidAuthException $e){
    // Handle the exception
} catch(Exception $e){
    // ...


If you are using it with laravel you can set the service provider and the facade.

Service Provider

'providers' => [


'facades'   => [
    'MyRouter'     => NikhilPandey\TpLink\Facades\TpLink::class,

After doing so, you can use the program as follows.

    ->setAuth($routerUsername, $routerPassword)

    ->setAuth($routerUsername, $routerPassword)


This package is open-sourced software licensed under the MIT license

You can’t perform that action at this time.