Could not find key "csrf" in tree at Zend Expressive project

94 views Asked by At

I got a Zend Expressive application running with Docker. Normally this project runs, but when I added it to a bitbucket repository, and then git cloned it, built with docker, and then went to localhost:8000 it gave me this error:

[![enter image description here][1]][1]

The weird part is that I have an exact copy locally which works, but IF its uploaded to a repository, then git cloned, and try to run it gives this error. I'm not sure what part is causing it, there is also NO information online about this error.

I'm going to show some config files as I'm not even sure what I should be showing:

Docker:

version: '3'

services:
  php:
    build: ./docker/php
    depends_on:
      - postgres
      - redis
    volumes:
      - .:/var/www/html

  nginx:
    image: nginx:1.11
    depends_on:
      - php
    ports:
      - '8000:80'
    volumes:
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
      - .:/var/www/html

  postgres:
    image: postgres:9.6
    ports:
      - '5438:5432'
    volumes:
      - 'postgres-data:/var/lib/postgresql/data'
  redis:
    image: redis:3.2

  build:
    build: ./docker/build
    volumes:
      - .:/var/www/html

volumes:
  application-data:
  postgres-data:

Composer:

{
    "name": "project/project",
    "type": "project",
    "require": {
        "php": "^7.1",
        "psr/http-message": "^1.0",
        "zendframework/zend-servicemanager": "^3.1",
        "zendframework/zend-config": "^2.6",
        "zendframework/zend-expressive": "^2.0",
        "zendframework/zend-expressive-fastroute": "^2.0",
        "zendframework/zend-expressive-platesrenderer": "^1.3",
        "zendframework/zend-config-aggregator": "^0.2.0",
        "psr/log": "^1.0",
        "zendframework/zend-log": "^2.9",
        "zendframework/zend-progressbar": "^2.5",
        "psr/simple-cache": "^1.0",
        "cache/redis-adapter": "^1.0",
    },
    "autoload": {
        "psr-4": {
            "Project\\": "src/"
        }
    }
}
1

There are 1 answers

2
AudioBubble On

Looking at the error my first guess is your configuration is not correct. Maybe you have set your local csrf key in a ./config/autoload/local.php file? Local config files are ignored by git by default.

Looks like you are missing something like this:

<?php
return [
    'csrf_guard' => [
        'csrf' => [
            'lifetime' => 3600,
        ],
    ],
];

You can check out an example config here: https://github.com/DASPRiD/CSRF-Guard/blob/master/doc/example-config.php