Fatal error: Uncaught Error: Class "Source Models Post"

Asked

Viewed 109 times

0

I am unable to instantiate the object, my class inside the source/Models folder

<?php 

namespace Source\Models;

use CoffeeCode\DataLayer\DataLayer;

class Post extends DataLayer
{
    public function __construct()
    {
        parent::__construct("post",["title","description"]);
    }
}

My generate.php that is in the root folder

<?php 

require __DIR__ . "/vendor/autoload.php";

use Source\Models\Post;
use Faker\Provider\Image;
use Faker\Provider\Lorem;


for ($i=0; $i < 1; $i++) { 
    $post = New Post;
    $post->title = lorem::text(80);
    $post->cover = Image::image("/images", 300, 150);
    $post->description = Lorem::paragraph(2,true);

    var_dump($post);
}

my file . json

{
    "name": "rtsgo/blog",
    "description": "blog com pagina\u0000\u0000o",
    "require": {
        "fzaninotto/faker": "^1.9",
        "coffeecode/datalayer": "^1.1",
        "coffeecode/paginator":"^1.0"
    },
    "authors": [
        {
            "name": "Renan Teotonio",
            "email": "[email protected]"
        }
    ],
    "autoload": {
        "psr-4": {
            "Source\\":"source/"
        },
        "files": [
            "source/Config.php"
        ]
    }
}

my folder structure

inserir a descrição da imagem aqui

I’m using PHP 8, but always gives error

Fatal error: Uncaught Error: Class "Source Models Post" not found in C: xampp htdocs BLOG generate.php:11 Stack trace: #0 {main} thrown in C: xampp htdocs BLOG generate.php on line 11

  • 2

    The class Post is not being loaded before use

  • Important to improve your question by clicking [Edit]. Which folder this class comes from Post? Using an autoload? Poser? Provide a [mcve]

  • Spun composer dump?

  • how can I carry the Class before?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.