Welcome Guest, Not a member yet? Register   Sign In
Trouble installing Shield
#1

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!
Reply
#2

You execute composer update ?
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#3

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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(This post was last modified: 07-05-2024, 12:41 AM by Littlesciu.)

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
Reply
#5

If your using Composer don't use the code I posted, its for a manual install.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(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
Reply
#7

(This post was last modified: 07-05-2024, 03:17 AM by InsiteFX.)

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); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(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/t...pages.html

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

(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.
Reply
#10

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB