Reputation: 716
I have updated my Laravel app from 6 to 7 and then 8 without problems. However, when I try to build an my docker image, it fails at the composer install --no-dev -o
command. If I run the same command in my terminal, there is no error.
The error is
In Request.php line 335:
Argument 1 passed to Symfony\Component\HttpFoundation\Request::create() mus
t be of the type string, null given, called in /app/vendor/laravel/framewor
k/src/Illuminate/Foundation/Bootstrap/SetRequestForConsole.php on line 32
and the command used to build the image is @docker build $(DOCKER_BUILD_ARG) -t $(IMAGE_TAG) -f $(DOCKERFILE) .
It seems like it is a problem with a laravel framework file. I Googled this error but have not found any solution. I tried to run composer dump autoload, php artisan cache:clar and php artisan config:clear, none of these fixed my issue.
My dockerfile looks like this:
FROM armcanada/php7-mssql:latest
# Copy files
ADD . /app/
ADD php.ini /etc/php.ini
ADD arm-http.conf /etc/httpd/conf.modules.d/arm-http.conf
# Install app dependencies
RUN composer install --no-dev -o
# Fix permissions
RUN chmod -R 777 ./storage
RUN chmod -R 777 ./bootstrap/cache
# Cache route & views
RUN php artisan route:cache
RUN php artisan view:cache
CMD ["start_httpd"]
and my composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.3.0",
"armcanada/laravel-honeypot": "dev-master",
"bacon/bacon-qr-code": "^2.0",
"barryvdh/laravel-dompdf": "^0.8.6",
"box/spout": "^3.0.1",
"doctrine/dbal": "^2.7",
"erusev/parsedown": "^1.7",
"fideloper/proxy": "~4.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"hackzilla/password-generator": "^1.5",
"itsgoingd/clockwork": "^4.1",
"laravel/framework": "^8.0",
"laravel/helpers": "^1.3",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0",
"maatwebsite/excel": "^3.1",
"paragonie/constant_time_encoding": "^2.3",
"predis/predis": "^1.1",
"rickycezar/laravel-jwt-impersonate": "^1.3",
"spatie/laravel-permission": "^3.18",
"tymon/jwt-auth": "^1.0.0",
"yajra/laravel-datatables": "^1.4"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"Mz\\": "app/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/Support/Helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/armcanada/laravel-honeypot"
}
],
"extra": {
"laravel": {
"dont-discover": [
"tymon/jwt-auth"
]
}
}
}
Upvotes: 1
Views: 1776
Reputation: 716
I managed to solve it by editing the app/config.php
file.
The error was that the url
key was null so I added a default value to the env()
function:
'url' => env('APP_URL', 'default'),
Upvotes: 3
Reputation: 11
I was getting same error when I had the .env
file in before running composer install then it worked fine
Upvotes: 0