Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
December 21, 2013
Chris
Git, mini, MVC, PHP
8

Preview-release of (my) “php-mvc” project (a simple php mvc barebone)

PreviousNext
php mvc

php-mvc

Voila! The very first pre-final release of the “php-mvc” repository is online: https://github.com/panique/php-mvc and http://www.php-mvc.net. It’s a very simple but very useful barebone application written in PHP. This little thing is not another framework, it is simply a totally reduced file-and-folder structure that should 1.) help developers to create PHP applications without a framework the right way and 2.) show younger devs how “good” code could look like and how MVC applications are structured. I know, some people will scream now “but why you don’t learn Zend2 etc. ?”, but that’s exactly the point: Many younger developers simply have problems to learn Zend2 etc.! Most mainstream frameworks, even the micro ones, are really hard to understand, even with some years of PHP experience.

It’s a common problem that masses of non-professional developers try to build PHP applications in their own way, without having ever heard of MVC or how to organize such a project. This usually results in a quite wild and weird file structure, with more than 15 php files for just handling one little form, and a horrible mix of database requests, HTML and CSS and php-generated JavaScript. I think we all have gone through this. The php-mvc project/repository (I’m still in the name-finding process) tries to solve that problem by providing an extremely easy-to-learn skeleton application for PHP projects, while it DOES NOT try to be a real framework. Everything is as non-automatic as possible. Everything is as clean as possible, as reduced as possible.

The project aims at people with shorter PHP experience, but tries to fit the most modern PHP standards at the same time. We are talking about PSR-1/2, autoloaders, Composer, PDO, MVC for sure, potential Unit Testing (just a plan!), Post/Redirect/Get, speaking variables/methods, proper comments etc.

To give a short introduction how this project looks and behaves, check out these 5 tutorials I’ve made (they are currently images, as this is the best possibility to bring stuff like that into a GitHub README file): And, you’ll find a file/folder structure explanaition on the last one.

php mvc tutorial - part 1

php mvc barebone tutorial part 2

php mvc barebone tutorial part 2

php mvc barebone tutorial part 4

php mvc barebone tutorial part 5

Looks quite okay I think. It would be awesome if everybody who’s interested could try out this thing and give feedback, commit improvements or just send hatemails because this project is totally useless. The repo URL is https://github.com/panique/php-mvc, feel to do whatever you want with this skeleton app.

 

This article was written quite a while ago (9 years), please keep this in mind when using the information written here. Links, code and commands might be outdated or broken.

Random articles

  • New project: Building a naked PHP skeleton / boilerplate application from scratchNew project: Building a naked PHP skeleton / boilerplate application from scratch
  • Install MINI in 30 seconds inside Ubuntu 14.04 LTSInstall MINI in 30 seconds inside Ubuntu 14.04 LTS
  • The first micro framework written in Hack is there: hack-mvc !The first micro framework written in Hack is there: hack-mvc !
  • PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)
  • What’s new in PHPStorm 9What’s new in PHPStorm 9
  • Experimenting with HHVM at Etsy (Link)Experimenting with HHVM at Etsy (Link)
  • Dangerous Performance Myths in the Web (video talk by Thomas Lohner, PHPUG Latvia)Dangerous Performance Myths in the Web (video talk by Thomas Lohner, PHPUG Latvia)
  • MINI2, an extremely simple barebone PHP application on top of SlimMINI2, an extremely simple barebone PHP application on top of Slim
  • MINI, an extremely simple barebone PHP applicationMINI, an extremely simple barebone PHP application
MVCPHPphp-mvc
Share this

8 Comments

  • bito
    August 7, 2014 6:49 pm

    Hello

    I’m starting with PHP-MVC and I have tried to write a function that gets music using the artist’s name. I couldn’t get any result from de DB

    Could you please take a look at my code below and give me a hint about what is going wrong?

    Just two notes:
    . the variable $musics (in the next block of code) is always undefined (even after the has been submited)
    . these are the only changes I made

    Thank you very much
    bito

    /////////////////////////////////////////////////////////////////////////////////
    added in songsapplicationviewssongsindex.php
    —————————————————————-

    Choose a song by artist’s name
    <form action="songs/getsong” method=”POST”>
    Artist

    Id
    Artist
    Track
    Link

    id)) echo $music->id; ?>
    artist)) echo $music->artist; ?>
    track)) echo $music->track; ?>

    link)) { ?>
    <a href="link; ?>”>link; ?>

    /////////////////////////////////////////////////////////////////////////////////
    added in songsapplicationcontrollersongs.php
    ———————————————————————————

    public function getSong()
    {
    if (isset($_POST[“submit_get_song”])) {
    // load model, perform an action on the model
    $songs_model = $this->loadModel(‘SongsModel’);
    $musics = $songs_model->getSong($_POST[“artists_name”]);
    }
    header(‘location: ‘ . URL . ‘songs/index’);
    }

    /////////////////////////////////////////////////////////////////////////////////
    added in songsapplicationcontrollersongs.php
    ———————————————————————————

    public function getSong($artists_name)
    {
    $artists_name = strip_tags($artists_name);
    $sql = “SELECT * FROM song WHERE artist LIKE :artists_name “;
    $query = $this->db->prepare($sql);
    $query->execute(array(‘:artists_name’ => $artists_name));
    return $query->fetchAll();
    }

    Reply
  • deita
    April 23, 2014 11:57 pm

    Hello your project are amazing, but i have a question, how i make a jQuery
    Ajax GET and POST calls to controller methods and get these arguments? for example in my js
    $.post(‘../myController/myAction’, {
    arg: “hello”,
    arg2: “world”
    });

    in my controller
    …
    public function myAction(){
    var_dump($_POST);
    }
    the server response: array(0) {
    }
    Thanks and sorry for my poor english

    Reply
    • Chris
      April 24, 2014 10:17 am

      Good question! I’ve created a ticket on https://github.com/panique/php-mvc/issues/70 to create a demo ajax call and integrate it into the tutorial. Expect this to be ready within some days!

      Reply
  • Tedd
    March 25, 2014 3:07 am

    Hey man, I am the exact person this thing is made for. Thank you so much for creating this. I’m struggling a bit with some things, but learning a ton about proper coding standards.

    Would love to see a full project built upon it, so I could see how a real world project might be further organized and built upon it.

    Reply
  • Ken
    February 13, 2014 8:14 pm

    Great framework! Job well done. It’s fast and lean. Just the way I like to write code. Keep up the development. You’ve got something here.

    Reply
  • Henry Withoot
    January 4, 2014 11:00 am

    I love the framework and i did some post on your forum.
    Currently i try to use a different approach for the views and i succeed.
    https://bitbucket.org/krzysztofr/sm-view/src/dea3cf49c496337407cd42ca745444242273b1ff/custom-class/MyView.php?at=default but initially i would like to work with TWIG.I also have intentions to include something like boxes for left/right or whatever position, of course with a admin interface.
    The posts i made on your forum under the name : osc2nuke
    ;)

    Reply
    • Chris
      February 9, 2014 4:10 am

      Thanks :) … there’s a new “branch” of the php-mvc in https://github.com/panique/php-mvc-advanced, with Twig support. More features likes ORM, SASS, routing etc. are planned! Feel free to check this out.

      Reply
  • Xavier
    December 21, 2013 10:08 pm

    Extremely useful, thanks for your work!

    I have been building one myself for the last few weeks as I refuse to use a big third party framework for an own project, so even if this comes a bit late for me, I’m sure I will be able to grab some ideas from it :-)

    Reply

Leave A Comment Cancel reply

Disappointed by Watch Dogs’s graphics ? See how it looks with unlocked, hidden settings. Awesome!

When you are interested in 3D and game graphics in general, you probably stumbled upon these excellent and extremely good-looking

[Link] Redesigning SoundCloud by Evan Simoni

Again, an interesting approach / proof-of-concept on a redesign of a major website. Evan Simoni has overthought SoundCloud’s UI and

O’Reilly’s Programming JavaScript Applications by Eric Elliott for free (Early Access release)

O’Reilly currently offers the entire book Programming JavaScript Applications by Eric Elliott for free (as an online-readable version) while its

css3-chrome-font

[Link] Retinafy your Site / Device by Nijiko Yonskai

A simple one-page Gist with all the information you need to make your sites retina-ready: Nijiko Yonskai – Retinafy your

php

How to install PHP curl extension (in 5 seconds)

It’s a common wordpress problem: PHP’s curl extension is not installed! No need to mess around in config files etc,

java vs php

Switching from Java to PHP. Seriously. A very interesting and pre-judice-free talk with Ph.D. Aris Zakinthinos

Ph.D. Aris Zakinthinos, CTO of achievers.com, a well-scalability-experienced guy and former IT employee of the military, has just delivered one

bash-command-line-tutorial

Best introduction to unix command line / bash ever (by André Augusto Costa Santos)

This article was written quite a while ago (9 years), please keep this in mind when using the information written

battlefield-3-free

Electronic Arts / Origin offers Battlefield 3 for free (limited promo action) !

A little bit off-topic, but definitly cool: EA offers the award-winning Battlefield 3 for free these days, but only for

Going node.js at Netflix (Slides by Micah R of Netflix)

It’s awesome how node.js takes over the absolute AAA-level corporate world. Note that node.js is still an early alpha product

bitdeli git github stats

Get visitor stats for your GitHub repo with BitDeli

GitHub is the definitive #1 “hoster” for git repositories, no question. And this highly sympathic company has made version control

1/4

Categories

Search

php uk conference
PHP Caching Best Practices by Eli White (video from PHP UK Conference 2014)
pdo-debug
Debug PDO with this one-line function. Yeah!
Material Design – How Google designed Android L (7min video)
photoshop-cc-deal
Adobe offers Photoshop for $9.99 per month (limited deal)
angular js
Learn AngularJS in 20 (or 90) minutes with Dan Wahlin
php
appserver.io – A New Way of Magento Enterprise Infrastructure (26min video talk)
dev coding cards deck
Nice gifts for devs: Nerdy playing-cards decks
css4
Angelina Fabbro talks about “CSS4” in this excellent conference video
php
Awesome list of Design Patterns with PHP code examples
hack-php
Wow! Facebook devs have rewritten and fixed PHP, releasing it as new language called “Hack” today
What’s new in PHPStorm 10 (Official promo video)
Frontend Ops Conf 2014 – Keynote by Alex Sexton: “Front End Operations”
php
Is there a JSFiddle for PHP ? Yes !
mod-rewrite-ubuntu-14-04-lts
How to enable mod_rewrite in Ubuntu 14.04 LTS
mod-rewrite-ubuntu-14-04-lts
Which server OS version to choose ? Some EOL lists of Debian, Ubuntu and CentOS

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy
 
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT