Simple PHP MVC framework

So, for several weeks now I have been playing with my own PHP MVC Framework, exclusively for training. I have the basics, and I think I know what is happening, and so on. But I still could not understand the following.

Say I have a music database, and I have a “music controller”, a “music model” and, obviously, a “musical look”. What I want to do is, of course, the ability to insert a new artist and / or a new track, I would also like to be able to edit them, etc. My url is as follows:

example.com/controller/mainfunction

In my "music controller" I have a method as follows:

public function addTrack()
{
    if (isset($_POST["submit_add_track"]))
    {
        // call the model to add track to database etc..
    }
}

, " " , . ..

. ? ? :

example.com/music/add/artist
example.com/music/add/track

-, , " ", , ? :

example.com/insert/artist
example.com/insert/track

, , , , .

, , , , "insert", " ", "insert track" ? , . , , .

, , ( ) . !

Edit: , , . , . addArtist, , , - , . , . , ? , . ? - ?

example.com/music/insertArtist

, "insertArtist", "addArtist" , , . , - , . , "addArtist" "addArtist" , , "if submit then add artist". , , ?

public function addArtist()
{
    // $artist_model->addArtist();
}


public function editArtist($artistID)
{
    // $artist_model->editArtist();
}


public function deleteArtist($artistID)
{
    // $artist_model->deleteArtist();
}


public function addTrack()
{
    // $artist_model->addTrack();
}


public function editTrack($trackID)
{
    // $artist_model->addTrack();
}


public function deleteTrack($trackID)
{
    // $artist_model->addTrack();
}
+4
2
example.com/music/addArtist
example.com/music/addTrack

/controller/method

, , . ,

/**
 * Executes the requested action
 */
public function ExecuteMethod($method)
{
    $this->{$method}();
}

addArtist addTrack .

, /controller/part apache, , /method/ , .

EDIT: - MVC, . MVC . , MVC , , MVC, .

2: ( ) , , .

- , . , .

, , ( ) , .

, , viewForm() submitForm(). , , addArtist(), editArtist() .., , , MVC.

, , , . , , , (Btw, , , " " , ). → :

  • /Artists/view → html
  • /Artists/viewAddForm → , .
  • /Artists/submitAdd → html
  • /Artists/viewEditForm →
  • /Artists/submitAdd → html
  • /Artists/delete → html

, . 3 .

  • "", , .
  • , , .
  • delete, , .

.

+3

, , - RESTful.

example.com/artist
example.com/track

HTTP- (POST/PUT/DELETE/GET)

, .

, . , . , , , .

+1

All Articles