slimphp / Tutorial-First-Application

Tutorial application code for the First Application Walkthrough
126 stars 49 forks source link

Tickets page not working as expected #8

Closed EdwinHuijsing closed 2 months ago

EdwinHuijsing commented 8 years ago

After installing the project in a sub directory the tickets page it did not work. It was not possible to add new items, the URL to add new items is wrong. When I changed it manually it worked. To solve it “easy way” I used a virtual site, but that is workable on the long run.

After some testing I removed the virtual site, but this time I was able to view the details without any problems. Then I note that view detail uses pathFor, but that is not done for Add new ticket. The URL for new tickets is hard coded.
From tickets.phtml
Line 9 <p><a href="/ticket/new">Add new ticket</a></p>
line 31 <a href="<?=$router->pathFor('ticket-detail', ['id' => $ticket->getId()])?>">view</a>

Is this done on purpose?

I solved it this way:
file index.php line 72 change

});

to

})->setName('ticket-new');

file tickets.phtml line 9 change

<p><a href="/ticket/new">Add new ticket</a></p>

to

<p><a href="<?=$router->pathFor('ticket-new')?>">Add new ticket</a></p>

Is this the way to go, or should it be done in an other way?

akrabat commented 7 years ago

I think it should use pathFor as you show.

akrabat commented 7 years ago

This will need an update to the text of the tutorial as well as the source code.

odan commented 2 months ago

As a starting point, please check the newer Slim-Skeleton repo: https://github.com/slimphp/Slim-Skeleton Closing this as resolved.