Connect with us

How to solve This page isn’t working HTTP ERROR 500 in Laravel

kizinho

Published

on

Follow
DEVELOPER PROGRAMMING: How to solve This page isn’t working HTTP ERROR 500 in Laravel [New  Developer Programming] » Naijacrawl
Photo: Naijacrawl

In case you ran into this problem This page isn’t working www.example.com is currently unable to handle this request HTTP ERROR here is the cause and how to fix it. First, it must not be an error from your code, it is an error from querying large data from your database. So request ran out of memory, to fix it follow this step.

In your Laravel root project folder locate this file

vendor/laravel/framework/src/Illuminate/
Database/Connection.php.

Insert this line of code after line 324 

ini_set('memory_limit', '-1'); 

or follow the code snippet or image below:


 public function select($query, $bindings = [], $useReadPdo = true)    {        return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {            if ($this->pretending()) {                return [];            }            // For select statements, we'll simply execute the query and return an array            // of the database result set. Each element in the array will be a single            // row from the database table, and will either be an array or objects.            ini_set('memory_limit', '-1');         

   $statement = $this->prepared($this->getPdoForSelect($useReadPdo)                              ->prepare($query));            $this->bindValues($statement, $this->prepareBindings($bindings));            $statement->execute();            return $statement->fetchAll();        });    }


site


kizinho

I am a software developer, like meeting people and love blogging, that's why I developed naijacrawl because that's what I love doing.

Continue Reading
Click To Comment

BE First To Comment


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Laravel 7 comes with Easy Implicit Route Model Binding

    kizinho

    Published

    on

    NEWS: Laravel 7 comes with Easy Implicit Route Model Binding [New  Developer] » Naijacrawl
    Photo: Naijacrawl

    Laravel 7 will be out 2020 with new awesome features. You can clean the way routing is been done with one line of code.

    But you can try the dev version by running this code

    laravel new example --dev
    


    In laravel 7 you can bind routes like this:


    Route::get('/posts/{post:slug}', function (Post $post) {
        // ...
    });
    
    


    Currently, Laravel 6 and below requires you to define a getRouteKeyName() method on the model like so:

    <?php
    
    class Post extends Model
    {
        /**
         * Get the route key for the model.
         *
         * @return string
         */
        public function getRouteKeyName()
        {
            return 'slug';
        }
    }
    


    You can use the below route binding when you have multiple routes that you want to bind differently.

    For example, the frontend route uses slugs to display posts and backend admin uses ids to manage posts:


    Route::get('/posts/{post:slug}', function (Post $post) {
        // ...
    });
    
    // Or you could use the default `{post}` here...
    Route::get('/admin/posts/{post:id}/edit', function (Post $post) {
        // ...
    });
    


    Thanks for reading.



    Continue Reading

    Laravel 6.5.2 Released this week for bug fix

    kizinho

    Published

    on

    NEWS: Laravel 6.5.2 Released this week for bug fix [New  Developer] » Naijacrawl
    Photo: Naijacrawl

    The Laravel team released v6.5.2 this week—this version is a patch version release, containing mostly changes and fixes.

    Here’s a few things of note:

    • If you’re using PostGIS types in Postgres, Laravel now supports a separation between geometry and geography types.
    • The BelongsToMany::cursor() method, now hydrates pivot relations.
    • Model serialization on jobs allows typed properties.

    You can see the full list of new features and updates below and the whole diff between 6.5.1 and 6.5.2 on GitHub. The full release notes for Laravel 6.0 are available in the GitHub v6 changelog:

    v6.5.2

    Added

    • Allowed model serialization on jobs for typed properties (#30604, #30605, 920c364)
    • Allowed fallback when facade root accessor has previously been resolved (#30616)
    • Added support for separation between geometry and geography types for Postgres (#30545)
    • Added createWithContent() method to Illuminate\Http\Testing\File and Illuminate\Http\Testing\FileFactory (2cc6fa3, 181db51)

    Refactoring

    • Improved PostgresGrammar::formatPostGisType() method readability (#30593)

    Changed

    • Added symfony/debug dependency to illuminate/pipeline (#30611)
    • Override BelongsToMany::cursor() to hydrate pivot relations (#30580)
    • Ignore Redis prefix when verifying channel access in RedisBroadcaster (#30597, d77ce36)


    Continue Reading

    How to Automate App Setup with Laravel Initializer

    kizinho

    Published

    on

    NEWS: How to Automate App Setup with Laravel Initializer [New  Developer] » Naijacrawl
    Photo: Naijacrawl

    Have you ever found yourself writing multiple manual steps to set up a Laravel application in a new environment? Laravel Initializer is a convenient way to automate installing and updating a Laravel application:

    Laravel Initializer gives you the ability to declare multiple processes and run them with app:install and app:update artisan commands, which run predefined actions chain depending on the current environment.

    The app:install and app:update commands use two distinct classes that run commands based on a given environment. First, the install command uses the App\Install class:

    namespace App;
    
    use MadWeb\Initializer\Contracts\Runner;
    
    class Install
    {
        public function production(Runner $run)
        {
            return $run
                ->external('composer', 'install', '--no-dev', '--prefer-dist', '--optimize-autoloader')
                ->artisan('key:generate')
                ->artisan('migrate', ['--force' => true])
                ->artisan('storage:link')
                ->external('npm', 'install', '--production')
                ->external('npm', 'run', 'production')
                ->artisan('route:cache')
                ->artisan('config:cache')
                ->artisan('event:cache');
        }
    
        public function local(Runner $run)
        {
            return $run
                ->external('composer', 'install')
                ->artisan('key:generate')
                ->artisan('migrate')
                ->artisan('storage:link')
                ->external('npm', 'install')
                ->external('npm', 'run', 'development');
        }
    }
    
    

    The app:update command looks similar, using an App\Update class:

    namespace App;
    
    use MadWeb\Initializer\Contracts\Runner;
    
    class Update
    {
        public function production(Runner $run)
        {
            return $run
                ->external('composer', 'install', '--no-dev', '--prefer-dist', '--optimize-autoloader')
                ->external('npm', 'install', '--production')
                ->external('npm', 'run', 'production')
                ->artisan('route:cache')
                ->artisan('config:cache')
                ->artisan('event:cache')
                ->artisan('migrate', ['--force' => true])
                ->artisan('cache:clear')
                ->artisan('queue:restart'); ->artisan('horizon:terminate');
        }
    
        public function local(Runner $run)
        {
            return $run
                ->external('composer', 'install')
                ->external('npm', 'install')
                ->external('npm', 'run', 'development')
                ->artisan('migrate')
                ->artisan('cache:clear');
        }
    }
    
    

    You can also inject dependencies from the service container if you need to access services while running commands.

    This package contains a variety of runner actions you should check out in the readme. I found the MakeCronTask dispatch interesting:

    $run->dispatch(new \MadWeb\Initializer\Jobs\MakeCronTask)
    
    

    MakeCronTask adds the following to the server’s crontab list:

    * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
    
    

    You can do other things like creating a supervisord config for a typical queue worker or horizon.

    You can learn more about this package, get full installation instructions, and view the source code on GitHub at mad-web/laravel-initializer.

    Continue Reading

    Latest



    Face of Naijacrawl


    ChukwubuikemSunday ChukwubuikemSunday

    Sunday Chukwubuikem


    Higher - 09061773292

    Trending