Skip to content

Issue building sites using ApiPlatform #179

@tacman

Description

@tacman

I have a simple site that I'd like to build as a set of static page. It's failing when trying to generate the API platform routes, and I'm not sure how to exclude them. Obviously API Platform is going to require an actual server, but I think the issue is with the documentation, which ideally would work with static files. Regardless, I would like to be able to exclude it so the rest of the site builds.

"channel":"console","datetime":"2023-11-06T16:53:17.709953+00:00","extra":{}}
16:53:17 CRITICAL  [console] Error thrown while running command "-e prod stenope:build './public/static'". Message: "Could not build url http://localhost/api/index.jsonopenapi." ["exception" => Exception { …},"command" => "-e prod stenope:build './public/static'","message" => "Could not build url http://localhost/api/index.jsonopenapi."]
{"message":"Command \"-e prod stenope:build './public/static'\" exited with code \"1\"","context":{"command":"-e prod stenope:build './public/static'","code":1},"level":100,"level_name":"DEBUG","channel":"console","datetime":"2023-11-06T16:53:17.715661+00:00","extra":{}}
In Builder.php line 386:
                                                               
  Could not build url http://localhost/api/index.jsonopenapi.  
                                                               

Here's the bash commands to create the problem.

symfony new crawler-7 --webapp --version=next --php=8.2 && cd crawler-7
composer config extra.symfony.allow-contrib true
echo "DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db" > .env.local
composer req api
composer require orm-fixtures --dev            
echo "officialName,string,48,no," | sed "s/,/\n/g"  | bin/console make:entity Official
bin/console doctrine:schema:update --force --complete

bin/console make:crud Official -q
bin/console make:fixture CongressFixtures
cat > src/DataFixtures/AppFixtures.php <<'END'
<?php

namespace App\DataFixtures;

use App\Entity\Official;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

class AppFixtures extends Fixture
{
    public function load(ObjectManager $manager): void
    {
        $url = 'https://theunitedstates.io/congress-legislators/legislators-current.json';
        $json = file_get_contents($url);
        foreach (json_decode($json) as $record) {
            $name = $record->name;
            $official = (new Official())
                ->setOfficialName($name->official_full ?? "$name->first $name->last");
            $manager->persist($official);
        }
    $manager->flush();
    }
}
END

bin/console d:fixtures:load -n

composer require stenope/stenope
bin/console -e prod cache:clear
bin/console -e prod stenope:build ./public/static

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions