CodeIgniter Forums
Trouble installing Shield - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Trouble installing Shield (/showthread.php?tid=91217)

Pages: 1 2


Trouble installing Shield - Littlesciu - 07-04-2024

Hi everyone,

I'm new to COdeIgniter and trying to install Shield.

I have CI installed correctly, I have Shield installed but when I go to run the command:

Code:
php spark shield:setup

I receive the message:

Code:
Command "shield:setup" not found.

At this point I follow the manual installation guide but when i have to execute the command:

Code:
php spark migrate --all

I receive the message:

Code:
Call to a member function routes() on null

at APPPATH\Config\Routes.php:11

Does anyone know how I can solve it?
Thanks!


RE: Trouble installing Shield - ozornick - 07-04-2024

You execute composer update ?


RE: Trouble installing Shield - InsiteFX - 07-05-2024

If you install manually, Shield will not work if it is not configured in the app/Config/Autoload,php.
Example:
I Use my name for namespace
Root
app
system
public
---- index.php
InsiteFX
-- Blog
-- etc.
app/Config/Autoload.php
PHP Code:
    public $psr4 = [
        APP_NAMESPACE => APPPATH,
        // InsiteFX Code Modules.
        'InsiteFX\Admin'        => ROOTPATH 'InsiteFX/Admin',          // InsiteFX/Admin Module
        'InsiteFX\Blog'        => ROOTPATH 'InsiteFX/Blog',          // InsiteFX/Admin Module
        // Shield Auth Modules.
        'CodeIgniter\Settings'  => ROOTPATH 'InsiteFX/settings/src',  // Settings Module
        'CodeIgniter\Shield'    => ROOTPATH 'InsiteFX/shield/src',    // Shield Auth Module
    ];

NOTEthe slashes \ / on paths



RE: Trouble installing Shield - Littlesciu - 07-05-2024

Hi,

@ozornick: Yes i do, but doesn't work.

@InsiteFX: 
My CI installation is new, I just created the first tutorial page, so my directories are:

appstarter
-app
-public
-test
-vendor
-wirtable

I modify autoload as follow
PHP Code:
  */
    public $psr4 = [
        APP_NAMESPACE => APPPATH// For custom app namespace
        'Config'      => APPPATH 'Config',
        // Shield Auth Modules.
          'CodeIgniter\Settings'  => ROOTPATH 'codeigniter4/settings/src'//Settings Module
        'CodeIgniter\Shield'    => ROOTPATH 'codeigniter4/shield/src',    // Shield Auth Module
    ]; 

But I receive alwayse the same error that depends on

in Routes.php
PHP Code:
// Shield
service('auth')->routes($routes); 

the full code of Routes.php is:

PHP Code:
<?php

use CodeIgniter\Router\RouteCollection;
use 
App\Controllers\Pages;


/**
 * @var RouteCollection $routes
 */

$routes->get('/''Home::index');

$routes->get('pages', [Pages::class, 'index']);
$routes->get('(:segment)', [Pages::class, 'view']);

// Shield
service('auth')->routes($routes); 


If it helps, I have the directories in the XAMPP htdocs


RE: Trouble installing Shield - InsiteFX - 07-05-2024

If your using Composer don't use the code I posted, its for a manual install.


RE: Trouble installing Shield - Littlesciu - 07-05-2024

(07-05-2024, 01:18 AM)InsiteFX Wrote: If your using Composer don't use the code I posted, its for a manual install.



Ok, I've installed Shield by composer, but I have to do the manual setup because the command

Code:
php spark shield:setuppark shield:setup

doesn't work.

Now I removed your code but I still have the same problem  Sad
It seems like it can't find the routes function, but I don't understand how to tell it where it is


RE: Trouble installing Shield - InsiteFX - 07-05-2024

Did you rename the public folder?

Spark will not work if you move or rename the public folder.

If you did then you need to edit the Spark file and change the path to the public folder to the new path.

As below you can see I had to change it because my site uses public_html so I code with it like that.

PHP Code:
// Path to the front controller
define('FCPATH'__DIR__ DIRECTORY_SEPARATOR 'public_html' DIRECTORY_SEPARATOR); 



RE: Trouble installing Shield - Littlesciu - 07-05-2024

(07-05-2024, 03:14 AM)InsiteFX Wrote: Did you rename the public folder?

Spark will not work if you move or rename the public folder.

If you did then you need to edit the Spark file and change the path to the public folder to the new path.

As below you can see I had to change it because my site uses public_html so I code with it like that.

PHP Code:
// Path to the front controller
define('FCPATH'__DIR__ DIRECTORY_SEPARATOR 'public_html' DIRECTORY_SEPARATOR); 

No, I didn't rename any pages.

After installation of Code Igniter with compose I follow this tutorial:

https://www.codeigniter.com/user_guide/tutorial/static_pages.html

and it works, after I installed the official packages Settings and Shield.


RE: Trouble installing Shield - kenjis - 07-06-2024

(07-04-2024, 07:36 AM)Littlesciu Wrote: I have CI installed correctly, I have Shield installed but when I go to run the command:

Code:
php spark shield:setup

I receive the message:

Code:
Command "shield:setup" not found.

It shows you did not install Shield correctly.


RE: Trouble installing Shield - Littlesciu - 07-08-2024

What do you know, is there any incompatibility on XAMPP?
 Because composer didn't give me any errors, so I don't understand how to solve it.