Search code examples
phplaravelpyrocmsuser-registration

PyroCMS user registration error


So I'm a newbie at laravel framework and PyroCMS, I recently install PyroCMS and go to mydomain.com/register to try the registration function and I got the following error, but no idea how to solve it.

Error code:

}

/**
 * Convert the given string to upper-case.
 *
 * @param  string  $value
 * @return string
 */
public static function upper($value)
{
    return mb_strtoupper($value, 'UTF-8');
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Highlighted line
}

/**
 * Convert the given string to title case.
 *
 * @param  string  $value
 * @return string
 */
public static function title($value)
{
    return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
}

And

public static function substr($string, $start, $length = null)
{
    return mb_substr($string, $start, $length, 'UTF-8');
}

Which the line return mb_strtoupper($value, 'UTF-8'); and return mb_substr($string, $start, $length, 'UTF-8'); is highlighted with an error log expects parameter 1 to be string, array given.

How can I solve it?


More info:

Error file: pyrocms/vendor/laravel/framework/src/Illuminate/Support/Str.php

Error screenshot:

Error screenshot


Solution

  • You may or may not want to do something like this

    public static function upper($value)
    {
       if(is_array($value)){
             foreach($value as &$item){
                 $item = self::upper($item); //recursive
             }
             return $value;
       }
    
        return mb_strtoupper($value, 'UTF-8');
    }
    

    This will recursively call upper when it's an array and the effect will be that it will uppercase everything in $value. This may or may not be what you want.

    Chances are you are passing the wrong data to this method.

    To pass the right data you would do something like

    $value['key'] = Class::upper($value['key']);
    

    But I have no idea what value key should be, and I don't even know what class these methods reside in Class. I don't use laravel and I never heard of PyroCMS before.

    If I used every framework that came along i would spend my days learning frameworks and not building them. I don't use laravel because I don't like the syntax blade uses, I am not a fan of query builders, probably these can be replaced but we already have everything build in a different framework. So there is no need to customize it to work the way I want it to when we already have a solution that works just fine.

    That said, I do know PHP, I know it quite well in fact.