Welcome Guest, Not a member yet? Register   Sign In
Class not found Error, problem with namespaces
#5

With the appearance of namespaces in CI4, the location of certain libraries or helpers has become rather conditionaly.

Let's say you want to make a helper class and place it in the app/Helper directory

in file app/Helpers/Php2jquery.php
PHP Code:
<?php

namespace App\Helpers;

class 
Php2jquery {
    function phpArrayToJqueryParam($param, $indent = 0, $object = "", $wrapfunction = "") {
        return 'test';
    }


in file app/Controllers/Test.php
PHP Code:
<?php

namespace App\Controllers;

use 
App\Helpers\Php2jquery;

class 
Test extends BaseController {

    public function index() {
        $jqueryparam = new Php2jquery();

        $data[‘jqueryobject’] = $jqueryparam->php_array_to_jquery_param($param, 4, "new FWDRAP", "FWDRAPUtils.onReady(function(){" );

        return view('index'$data);
    }


Please note that the file and class name starts with a capital letter as recommended in the manual 
Reply


Messages In This Thread
RE: Class not found Error, problem with namespaces - by vitnibel - 12-01-2020, 07:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB