Welcome Guest, Not a member yet? Register   Sign In
[split] Ion-Auth with CI4
#11

(This post was last modified: 08-03-2020, 08:37 AM by jreklund.)

(10-29-2019, 03:20 AM)orionstar Wrote: As far as I know, the IonAuth 4 lacks the documentation entirely, the docs page is for IA3!
And yes, its uses the theme of <CI2 docs... there was a time when almost all large libraries had it and also the spin of frameworks copied it, just take a look at FuelPHP https://fuelphp.com/docs/

The documentation is for IonAuth 3 but also for IonAuth 4 ... The library was ported to be used in CI4 not rewriten... So, almost everything should look the same !

To install it, IT IS SUPER EASY ! Even without composer. (I dont like a script messing with my sh1t)...

Basically, you just need to extract tha IonAuth folder to the root-directory and change one config ! SUPER EASY !!!
Code:
CI 4.x                           # → Root Directory
├── app/
├── ion-auth/               # → Ion-auth directory
├── public
├──...
```
Then in your Config/Autoload.php, add this :
```php
'IonAuth' => ROOTPATH . 'YOUR-ION_AUTH-FOLDER',
```

Installing Ion Auth 4.x 
===================================

Before installing, please check that you are meeting the minimum server requirements.
Ion Auth 4 needs CodeIgniter 4.x and PHP 7.1.

There are different ways to install this package.


1. With composer

For an existing composer project:
```shell
$ composer config minimum-stability dev
$ composer config repositories.ionAuth vcs [email protected]:benedmunds/CodeIgniter-Ion-Auth.git
$ composer require benedmunds/CodeIgniter-Ion-Auth:4.x-dev
```

For a new project:
```shell
$ composer init
$ composer config minimum-stability dev
$ composer config repositories.ionAuth vcs [email protected]:benedmunds/CodeIgniter-Ion-Auth.git
$ composer require benedmunds/CodeIgniter-Ion-Auth:4.x-dev
```
---

2. With Git:

```shell
my-project$ git clone https://github.com/benedmunds/CodeIgniter-Ion-Auth.git
my-project$ cd CodeIgniter-Ion-Auth
CodeIgniter-Ion-Auth$ git checkout 4
```
Then in your Config/Autoload.php, add this :
```php
'IonAuth' => ROOTPATH . 'CodeIgniter-Ion-Auth',
```

---

3. Download the archive, and move folder from this package to the root folder:

```shell
CI 4.x                           # → Root Directory
├── app/
├── ion-auth/               # → Ion-auth directory
├── public
├──...
```
Then in your Config/Autoload.php, add this :
```php
'IonAuth' => ROOTPATH . 'YOUR-ION_AUTH-FOLDER',
```

---

### Relational DB Setup
Then use the migration file (in Database/Migrations/).
```
$ php spark migrate:latest -n IonAuth
```
Don't forget to set Config\Migrations:enabled to true.

You can also use the seeds file to insert default datas:
Windows :
```
$ php spark db:seed IonAuth\Database\Seeds\IonAuthSeeder
```
Linux :
```
$ php spark db:seed IonAuth\\Database\\Seeds\\IonAuthSeeder
```

---

### Use it
The most convenient way is to create a new controller like this :
```php
<?php namespace App\Controllers;

class Auth extends \IonAuth\Controllers\Auth
{
    /**
     * If you want to customize the views,
     *  - copy the ion-auth/Views/auth folder to your Views folder,
     *  - remove comment
     */
    // protected $viewsFolder = 'auth';
}
```
You can also add routes configs in 'Config\Routes.php':
```php
$routes->group('auth', ['namespace' => 'IonAuth\Controllers'], function ($routes) {
    $routes->get('/', 'Auth::index');
    $routes->add('login', 'Auth::login');
    $routes->get('logout', 'Auth::logout');
    $routes->get('forgot_password', 'Auth::forgot_password');
});
```
Reply


Messages In This Thread
[split] Ion-Auth with CI4 - by Poetawd - 10-26-2019, 07:33 PM
RE: [split] Ion-Auth with CI4 - by orionstar - 10-29-2019, 03:20 AM
RE: [split] Ion-Auth with CI4 - by Poetawd - 10-30-2019, 05:03 PM
RE: [split] Ion-Auth with CI4 - by MGatner - 11-01-2019, 06:12 AM
RE: [split] Ion-Auth with CI4 - by Poetawd - 11-01-2019, 06:53 AM
RE: [split] Ion-Auth with CI4 - by XTAZ - 11-12-2019, 12:51 PM
RE: [split] Ion-Auth with CI4 - by Poetawd - 11-12-2019, 06:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB