C
C
cryp242019-02-27 23:54:24
Composer
cryp24, 2019-02-27 23:54:24

Laravel After adding autoload - files to composer.json, post requests are no longer sent and cookies are not created on any pages (erorr 419)?

My initial task was to make functions that will be available from anywhere in Laravel.
On the Internet, I found that through composer.json autoload you can connect a file in which you specify this function and call it from anywhere without any problems.
So, as I did, I will write as accurately as possible so as not to miss anything:
1) I created a file with the app/Helper/addlog.php function (as it turned out later, the contents of the file do not affect the presence of a problem, I made it empty for the sake of testing)
2) I added the composer. json to make it look like this

"autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "files": [
            "app/Helper/addlog.php"
        ]
    }

3) I ran composer dump-autoload
I call the function as follows The function works fine Then I found that when opening pages, no cookies are created, no post requests are sent, any attempts to authorize or register lead to the page 419 Sorry, your session has expired. Please note that Laravel is absolutely clean, just installed, authorization is implemented automatically by migrating standard tables and running php artisan make:auth (nothing wrong with your hands) If you remove autoload from
addlog('name_files', 'text_log');
"files": [
            "app/Helper/addlog.php"
        ]

Then everything works fine, cookies are created, all requests start working.
Tell me what could be the problem or how can I solve the problem in another way, where can I put this function in laravel so that it is available from everywhere?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cryp24, 2019-02-28
@cryp24

The issue is resolved, the problem was in the file, namely that the <?php tag in the addlog.php file did not start from the first line, but from the second. Never would have thought that this is possible.
5c77130fb29b3346651336.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question