panique / mini

Just an extremely simple naked PHP application, useful for small projects and quick prototypes. Some might call it a micro framework :)
1.35k stars 478 forks source link

How to send a get parameter to a method in a controller? #242

Closed rakshithsj30 closed 5 years ago

juniorbatistadev commented 6 years ago

how?

panique commented 6 years ago

Hey, check this area of the readme, it explains this, it's super easy ! https://github.com/panique/mini#quick-start

panique commented 6 years ago

example.com/songs/editsong/17 will do what the editsong() method in application/controllers/songs.php says and will pass 17 as a parameter to it.

ezvr commented 5 years ago

is it possible to pass two or more parameters to the method? for example creating an API, which has several arguments, maybe how many values, and which database to get the values from..

panique commented 5 years ago

Good question, can you plz try out if this works (I dont have a dev computer right now here):

as URL example.com/songs/editsong/17/abc

and in https://github.com/panique/mini/blob/master/application/controller/songs.php use two parameters in the controller method, like public function editSong($song_id, $something)

Method 2: maybe simply use POST routes, like the delete/edit controller methods like public function addSong($artist, $track, $link) in https://github.com/panique/mini/blob/master/application/model/model.php

Hope it works out well for you :)

ezvr commented 5 years ago

Dear panique, thanks for your reply! I actually ended up implementing this using the _GET params inside my model functions, as such: $location = $_GET['location']; for url?location=XXX