rroycedev / roycedatabase-laravel
Allows delevepors to generate laravel database migrations and models
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^7.1.3
- fideloper/proxy: ^4.0
- laravel/framework: 5.6.*
- laravel/tinker: ^1.0
Requires (Dev)
- filp/whoops: ^2.0
- fzaninotto/faker: ^1.4
- mockery/mockery: ^1.0
- nunomaduro/collision: ^2.0
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-10-22 22:04:12 UTC
README
Requirements
Version 1.0.7
To use Adldap2-Laravel, your application and server must meet the following requirements:
- Laravel 5.*
- PHP 7.0 or greater
- PHP LDAP extension enabled
- An LDAP Server
Index
- Installation
- Usage
- Auth Driver
Installation
Run the following command in the root of your project:
composer require adldap2/adldap2-laravel
Note: If you are using laravel 5.5 or higher you can skip the service provider and facade registration and continue with publishing the configuration file.
Once finished, insert the service provider in your config/app.php
file:
Adldap\Laravel\AdldapServiceProvider::class,
Then insert the facade:
'Adldap' => Adldap\Laravel\Facades\Adldap::class
Publish the configuration file by running:
php artisan vendor:publish --tag="adldap"
Now you're all set!
Usage
First, configure your LDAP connection in the config/adldap.php
file.
Then, you can perform methods on your default connection through the Adldap
facade like so:
use Adldap\Laravel\Facades\Adldap; // Finding a user: $user = Adldap::search()->users()->find('john doe'); // Searching for a user: $search = Adldap::search()->where('cn', '=', 'John Doe')->get(); // Running an operation under a different connection: $users = Adldap::getProvider('other-connection')->search()->users()->get(); // Creating a user: $user = Adldap::make()->user([ 'cn' => 'John Doe', ]); // Saving a user: $user->save();
If you do not specify an alternate connection using getProvider()
, your
default
connection will be utilized for all methods.
Upon performing operations without specifying a connection, your default connection will be connected to and bound automatically using your configured username and password.
If you would prefer, you can also inject the Adldap interface into your controllers, which gives you access to all of your LDAP connections and resources as the facade.
use Adldap\AdldapInterface; class UserController extends Controller { /** * @var Adldap */ protected $ldap; /** * Constructor. * * @param AdldapInterface $adldap */ public function __construct(AdldapInterface $ldap) { $this->ldap = $ldap; } /** * Displays the all LDAP users. * * @return \Illuminate\View\View */ public function index() { $users = $this->ldap->search()->users()->get(); return view('users.index', compact('users')); } /** * Displays the specified LDAP user. * * @return \Illuminate\View\View */ public function show($id) { $user = $this->ldap->search()->findByGuid($id); return view('users.show', compact('user')); } }
To see more usage in detail, please visit the Adldap2 repository.