0

When I run the php artisan migrate command in terminal I'm left with this.

   ParseError 

  syntax error, unexpected ')'

  at C:\laragon\www\testnum2\vendor\laravel\framework\src\Illuminate\Bus\BusServiceProvider.php:51
     47▕             return new DatabaseBatchRepository(  
     48▕                 $app->make(BatchFactory::class), 
     49▕                 $app->make('db')->connection(config('queue.batching.database')),
     50▕                 config('queue.batching.table', 'job_batches'),
  ➜  51▕             );
     52▕         });
     53▕     }
     54▕
     55▕     /**

  1   C:\laragon\www\testnum2\vendor\composer\ClassLoader.php:322
      Composer\Autoload\includeFile("C:\laragon\www\testnum2\vendor\composer/../laravel/framework/src/Illuminate/Bus/BusServiceProvider.php")

  2   [internal]:0
      Composer\Autoload\ClassLoader::loadClass("Illuminate\Bus\BusServiceProvider")
PS C:\laragon\www\testnum2>

I'm not quite sure what is causing but this is the code for that file thats causing the error.

<?php

namespace Illuminate\Bus;

use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
use Illuminate\Contracts\Bus\QueueingDispatcher as QueueingDispatcherContract;
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;

class BusServiceProvider extends ServiceProvider implements DeferrableProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(Dispatcher::class, function ($app) {
            return new Dispatcher($app, function ($connection = null) use ($app) {
                return $app[QueueFactoryContract::class]->connection($connection);
            });
        });

        $this->registerBatchServices();

        $this->app->alias(
            Dispatcher::class, DispatcherContract::class
        );

        $this->app->alias(
            Dispatcher::class, QueueingDispatcherContract::class
        );
    }

    /**
     * Register the batch handling services.
     *
     * @return void
     */
    protected function registerBatchServices()
    {
        $this->app->singleton(BatchRepository::class, DatabaseBatchRepository::class);

        $this->app->singleton(DatabaseBatchRepository::class, function ($app) {
            return new DatabaseBatchRepository(
                $app->make(BatchFactory::class),
                $app->make('db')->connection(config('queue.batching.database')),
                config('queue.batching.table', 'job_batches'),
            );
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return [
            Dispatcher::class,
            DispatcherContract::class,
            QueueingDispatcherContract::class,
            BatchRepository::class,
        ];
    }
}

I hope that this is enough to get help. I wanna also mention that I've used php artisan migrate before and recently I had to upgrade some things like composer and phpmyadmin

2
  • 1
    what php version are you using? Commented Oct 4, 2020 at 11:21
  • Mostly likely It's trailing comma in the function call: config('queue.batching.table', 'job_batches'), and you have php 7.2 (or older), where is was not yet allowed. Commented Oct 4, 2020 at 11:25

2 Answers 2

1

The problem is that the PHP version you're using ( below 7.3 ) does not support trailing comma in function calls.

Please read this: Trailing Commas are allowed in Calls

Solution is to switch to > PHP 7.3

Sign up to request clarification or add additional context in comments.

6 Comments

is there a reason for the comma. it works when i deleted the comma. So just for confirmation this wont cause in problems in the future right?
you are not supposed to change anything in vendor directory. because one single update can break your entire site, because your change won't be there. I'd suggest you to use php7.3 or use laravel 7 instead.
when i ran <?php phpinfo() ?> it showed up as PHP 7.4.11. im not that experienced so is it possible that i downloaded the wrong one. it was php-7.4.11-Win32-vc15-x64.zip on the official site
@MuamarCollins that's strange. if you're using php7.4 then you shouldn't have had that issue.
yea, do you think maybe its a problem with phpmyadmin or something. I may just reinstall laragon and then i can probably pin point what exactly it is. i didnt have this problem before updating that.
|
1

Well my problem was my PHP being <7.3

But when I simply checked it in phpinfo file it showed up as 7.4.11.

@lagbox helped me by saying : "there are different versions on your system, and the CLI and the webserver can have different configurations"

To be honest I wasn't sure exactly what to do from that but I decided to just delete PHP 7.2 from my PATH.

  • My hope was that it would then recognize I was using 7.4 and to my suprise it did.
  • Also I'm sure there are more effective ways of doing this but that was the way I chose.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.