Code Monkey home page Code Monkey logo

yii2-subway's Introduction

Technical challenge

See below for personal reflections...


A fun technical challenge to find out how familiar you are with PHP, MySQL and Yii2 (and a little frontend work).

Summary

At the office we often order sandwiches at a local sandwich­shop. Right now everybody that wants to have a sandwich needs to write down their preferred choice.

We need a Yii2 application backed by a MySQL database to manage this (very complex) process.

A administrator should be able to add users (people that are going to eat the sandwich). The administrator should open up “registration” for a new meal. That stops people from ordering subway meals all the time. A meal has a status that can be controlled by the admin (open and closed).

Only one meal can be “open” at a single time. And only on a open meal users can register their choice. A meal also has a date (the date that we had the meal).

A meal should also have a unique link. This link can be opened on a mobile device (without a password) to check what the current order is.

Every user should have a unique code he can login with on a certain page. On that page the user can pick:

  • What bread (dropdown list, choices from database)
  • Size of the bread (dropdown, 15 or 30 cm)
  • If it should be oven baked or not
  • Taste of the sandwich (dropdown from database, for instance chicken fajita)
  • Extra’s (extra bacon, double meat or extra cheese)
  • What vegetables you want on the sandwich (dropdown, multiple possible values from the database)
  • What sauce (dropdown from the database)

Then the user can place his order (on the current open order). The user must be able to edit his order (but only when the order is still open). The user should also be able to view his previous orders when he is “logged in” by his unique link.

Steps

  • Create a datamodel (using MySQL workbench)
  • Install the datamodel in a MySQL database
  • Install Yii2 with composer
  • Generate model code and CRUD code with Gii
  • Improve the code for user friendliness
  • ????
  • PROFIT!!!

Bonuspoints

  • Whenever the user needs to place a new order, his previous order will automatically be prefilled in the form
  • On the unique link of the admin, the GPS location of the mobile phone of the “subway retrieving user” should be tracked and available on the unique links of all the users (on a Google map)
  • Users should be able to rate their experience with a meal, so they can see if they should order the same meal again
  • A button on the “admin mobile page” can be pressed to call ahead using MessageBird to the subway restaurant, that a big order is coming their way ;)
  • You unit-test and acceptance-test the “complex” application

Reflections

Yii Project

This is my first Yii2 project. Switching from my experience in Laravel (5 - 8), I had to learn Yii from scratch.

This little project shows my learning curve as was as the way I would normally handle programmiung assignments. It's a fun project to start. Should not have to take too mutch time.

Whitch is exactly the problem: time. Or... the lack of time. This project is done in what little spare time I could offer. So it might take a bitr longer than usual...

What I think of Yii2

The demo's I've read all push the models into a single directory. Cluttering that same folder with models for forms. Personally, I'd like to destinguish more within the models, seperating them by namespace and/or file hierarchy. And I'm not sure the forms definitions belong with the models.I guess it would be easier to split form functionality from the database model, but If that's the way to go, maybe create e new namespace: user\forms?

Methods

Install scripts

I did checkout these scripts, but ended up reverting my changes, the reason in the link title:

Database setup

I set up the database using DBeaver. While perhaps not as versitile as the MySQL Workbench, I had less trouble updating on my system running Arch Linux. (I also enjoyed working with Valentina Studio.) Because this database is outside of version control (GIT) I added the creation script to migrations. In order to run this setup on your own system, change the config/db.php file to have the desired values.

Coding Aid

Normally I use Atom for coding the web. Because I have my projects set up for my day job, I tried different alternatives:

  • Code - OSS: This program works great over slow SSH/network drives. I use this when I need LIVE hacks. Have it set up in a color theme wich reflects warning.
  • PhpStorm: I hear it's great, but I have a thing about paying personally what I use professionally.
  • Komodo Edit: I read about this one. Not on the top of my list, but a wanted a different editor than I use for my day-job, so why not try it? It will not replace my default (Atom), but it gets the job done.

Most of my GIT work, I do from the command line. I have met colleagues that simply do a commit -a, but I like to examen my changes. Try to create commit's containing all of the changes required for a feature. No more, no less. That would require these commands:

  • git status, git diff -w --color-words, git commit , git log, etc How about this one: git log --all --graph --oneline --simplify-by-decoration --date=short --pretty=format:"%C(yellow)%h%Creset%C(red)%C(bold)%d%Creset%C(white)(%cd)%Creset %s"
  • When searching the history I use smartGIT (no more then once a month). I hear PhpStorm has a great git utility build in.
  • Have have grown fond of the setup I have in Fish Shell, though I can also work with Zsh and Bash.

And of course the default linters. Most editors have these, but some can be used

  • php -l [filename] - automatic
  • phpcs - not default in Komodo Edit. I have it setup in Atom, reading either a local (project) or a global settings file. You could even set up git to block updates that do not meet the Coding Standard.
  • jshint - For some reason I can't use eslint on the terminal. So i use jshint there. Setup using .jshintrc.
  • eslint - Most editors have eslint rules checks. Those can be setup in the package.json or .eslintrc.js.

yii2-subway's People

Watchers

Herman M. Hofman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.