slimphp / tutorial-first-application Goto Github PK
View Code? Open in Web Editor NEWTutorial application code for the First Application Walkthrough
Tutorial application code for the First Application Walkthrough
https://github.com/slimphp/Tutorial-First-Application/blob/master/src/public/index.php#L43
$this->'router'
should be $this->router
@lornajane can you or anyone who did the migration right just put the .sql here?
Guess is more simple and fast to make things up.
thanks.
On Windows 7 professional the command php vendor/bin/phinx migrate
doesn't work, try it without php will run the migration successfully.
Here is what I found as a noob
Run php composer.phar install
Composer could not find a composer.json file in Tutorial-First-Application
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Fix by change the shell working directory to src
Run php vendor/bin/phinx migrate
[InvalidArgumentException]
There was a problem connecting to the database: SQLSTATE[HY000] [1045] Access denied for user 'user'@'localhost' (using password: YES)
Fix by creating the database to use first
Visit url /tickets
Slim Application Error
The application could not run because of the following error:
Details
Type: PDOException
Code: 1045
Message: SQLSTATE[HY000] [1045] Access denied for user 'user'@'localhost' (using password: YES)
File: Tutorial-First-Application/src/public/index.php
Line: 32
Fix by adjusting $config['db']
array in public/index.php
as well
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?
When ever a user redirects to default URL then it shows Page Not Found.
I wasted so much time to figure it out what is the issue with the application.
At last, I found out that the problem with the routes. So I feel it's better to redirect to tickets page.
Please let me if you want to implement this. I will create a merge request for this.
Thanks :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.