Setting up Slim Application
- Create a folder for your project, mine called
- create a
composer.jsonin the directory and open up your Command Prompt / Terminal and run
composer install. Later you should have something similar to Screenshot #2.
Setting up RedBeanPHP4
- Download RedbeanPHP4
- Create a folder named
RedBeanPHP4in vendor directory and extract download zip file above and copy the
slim/vendor/RedBeanPHP4– see Screenshot #2.
- Include the
- Then, add MySQL connection settings.
Let’s start it!
- Create a
index.phpin slim directory and add the following:
Basically what’s in this index.php is to add new user and view a user details.
- You may need to create new database, then new table named users. I used the following fields – id, name, email, created and modified
- Next, when the database and tables created, you may run
http://localhost/slim/users/add/Nasrul Hazimfirstname.lastname@example.org you may want to add more records. Suppose each time new user created, you will be redirected to the view user info page –
http://localhost/slim/users/view/1and see the next screenshot – I only var_dump the user details and you want to add some nice view or probably pass a JSON encoding.