TC
Twill CMS•3y ago
Kormi

Deploy with deployer and composer update

Hi, I'm tryng to deploy my project on a server with deployer (php). When I do "composer update" locally every works fine. But in staging or productions this error appears [staging] Generating optimized autoload files [staging] > Illuminate\Foundation\ComposerScripts::postAutoloadDump [staging] > @php artisan package:discover --ansi [staging] In RouteRegistrar.php line 107: [staging] Attribute [singleton] does not exist. [staging] Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 This is my composer.json { ... "require": { "php": "^7.3|^8.0", "area17/twill": "2.12.4", "area17/twill-image": "^1.0", "blade-ui-kit/blade-heroicons": "^1.2", "cweagans/composer-patches": "^1.7", "cwsdigital/twill-metadata": "^1.2.2", "fruitcake/laravel-cors": "^2.0", "kalnoy/nestedset": "^6.0", "laravel/sanctum": "^2.11", "laravel/tinker": "^2.5", "laravelium/sitemap": "^8.0", "mcamara/laravel-localization": "^1.7", "sendinblue/api-v3-sdk": "8.x.x", "ext-json": "*", "ext-pdo": "*", "astrotomic/laravel-translatable": "^11.5", "cartalyst/tags": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", "doctrine/dbal": "^2.12|^3.0", "guzzlehttp/guzzle": "^6.2|^7.0", "imgix/imgix-php": "^3.0", "laravel/framework": "~5.6|~5.7|~5.8|^6.0|^7.0|^8.0|^9.0", "laravel/socialite": "^4.2|^5.0", "laravel/ui": "^1.0|^2.0|^3.0", "league/flysystem-aws-s3-v3": "^1.0|^2.0|^3.0", "league/glide-laravel": "^1.0", }, "require-dev": { "chillerlan/php-qrcode": "~2.0|~3.0|~4.0", "deployer/deployer": "^7.1", "friendsofphp/php-cs-fixer": "^2.16|^3.0", "kalnoy/nestedset": "^5.0|^6.0", "orchestra/testbench": "~3.3|~3.4|~3.5|~3.6|~3.7|~3.8|^4.0|^5.0|^6.0|^7.0" },... Someone can help me please?
20 Replies
kallefrombosnia
kallefrombosnia•3y ago
Check the locked versions of the Laravel framework in the dev env and staging env, since packages are already installed.
Kormi
KormiOP•3y ago
I do not understand this is my env file LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug BROADCAST_DRIVER=log CACHE_DRIVER=file FILESYSTEM_DRIVER=local QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 MEMCACHED_HOST=127.0.0.1 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_MAILER=smtp MAIL_HOST=mailhog MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}" AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" IT is equals to staging env, a part of DB and APP variables
kallefrombosnia
kallefrombosnia•3y ago
Your env isnt wrong or something. Probably your staging updated to Laravel9 and that caused an issue since that introduced a new route method singleton which L8 didnt have and Twill had an own implementation of it. Check https://github.com/area17/twill/issues/1961 Not the same issue, but it could be related. Can you show us your RouteRegistrar.php?
GitHub
ā— [2.x] Too few arguments to function Illuminate\Routing\Router::si...
Summary In Laravel 9 a new Route::singleton method was added. This conflicts with our usage of the singleton macro. Because of this we have released Twill 2.12.0 which renames Route::singleton to R...
Kormi
KormiOP•3y ago
I already change singleton with TwillSingleton in admin.php ?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\Admin\LinkedinNewsController; Route::group([ 'prefix' => 'pages', 'middleware' => ['cache.headers'], ], function () { Route::module('pages'); Route::twillSingleton('homepage'); Route::twillSingleton('distributor'); :::
Kormi
KormiOP•3y ago
routeRegistrat.php
ifox
ifox•3y ago
you should not run composer update outside of your local environment. You should push your composer.lock file and run composer install during your deployment
kallefrombosnia
kallefrombosnia•3y ago
Thats a custom exception in your file.
if (! in_array($key, $this->allowedAttributes)) {
throw new InvalidArgumentException("Attribute [{$key}] does not exist.");
}
if (! in_array($key, $this->allowedAttributes)) {
throw new InvalidArgumentException("Attribute [{$key}] does not exist.");
}
/**
* The attributes that can be set through this class.
*
* @var string[]
*/
protected $allowedAttributes = [
'as',
'controller',
'domain',
'middleware',
'name',
'namespace',
'prefix',
'scopeBindings',
'where',
'withoutMiddleware',
];
/**
* The attributes that can be set through this class.
*
* @var string[]
*/
protected $allowedAttributes = [
'as',
'controller',
'domain',
'middleware',
'name',
'namespace',
'prefix',
'scopeBindings',
'where',
'withoutMiddleware',
];
ifox
ifox•3y ago
this is defaults from laravel
kallefrombosnia
kallefrombosnia•3y ago
Yeah true, name was a bit odd so thought is was a custom.
Kormi
KormiOP•3y ago
so i try to go back to "area17/twill": "2.11.0", InvalidArgumentException Attribute [twillSingleton] does not exist. locally i do composer update to "area17/twill": "2.12.4", Publishing complete. i push everithing (composer.lock) to my repo now i launch dep deploy In staging it do composer install --no-dev
Hro
Hro•3y ago
@Kormi ok
Kormi
KormiOP•3y ago
nothing
`@php artisan package:discover --ansi
[staging] In RouteRegistrar.php line 107: [staging] Attribute [singleton] does not exist. [staging] Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1`
Kormi
KormiOP•3y ago
if i look inside my project searching "singleton"
No description
ifox
ifox•3y ago
Which Route facade are you importing in your routes file?
Kormi
KormiOP•3y ago
use Illuminate\Support\Facades\Route; locally all works fine šŸ˜…
ifox
ifox•3y ago
GitHub
twill/RouteServiceProvider.php at ffc9b3705f29754f116b1267ad68ca51d...
Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/c...
Kormi
KormiOP•3y ago
i don't think it is the problem "singleton" is the problem in bootstrap/app.php i have this... $app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class ); $app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class ); but it is laravel mmmm
Kormi
KormiOP•3y ago
i do not know why... but in a way... composer get a older version f this file...
No description
ifox
ifox•3y ago
this is your file though, are you sure it's pushed and you're pulling the correct branch on the remote?
Kormi
KormiOP•3y ago
oh yes i pulling branch master instead of main 🤬

Did you find this page helpful?