Giter Club home page Giter Club logo

pvdleek / somda2 Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 50.08 MB

Somda is a trainspotting website. It consists of a web-application with automatic detection of mobile devices, a RSS feed-provider with several options and an API to be used within other web-applications or mobile apps.

Home Page: https://www.somda.nl/

CSS 2.87% HTML 0.02% JavaScript 2.29% PHP 62.22% Shell 0.17% Twig 31.79% Dockerfile 0.62%
trains trains-information trainspotting

somda2's Introduction

Somda

Introduction

This is the Somda repository. It consists of:

  • A web-application with automatic detection of mobile devices.
  • A RSS feed-provider with several options.
  • An API to be used within other web-applications or mobile apps.

Installation and configuration

Pre-requisites

Somda has the following system requirements:

  • PHP, minimum version 8.1
  • PHP extensions ctype, curl, gd, iconv and json
  • MySQL or MariaDB
  • A webserver such as Apache or Nginx
  • Preferably have ant installed: https://github.com/apache/ant

Getting started

Setting up a local environment requires the following steps:

  • Clone the repository
  • Copy the file .env to env.local in the root and adjust it to your environment. The keys WRONG_SPOTS_FORUM_ID, NS_API_PRIMARY_KEY and NS_API_SECONDARY_KEY are not important at this stage.
  • Import the database scripts into your local database in this order:
    • database/empty_database.sql
    • database/basic_data.sql
    • database/somda_trein.sql
    • database/somda_tdr_treinnummerlijst.sql
    • database/somda_tdr_trein_treinnummerlijst.sql
    • database/somda_tdr_drgl.sql
    • database/somda_tdr.sql
    • database/somda_tdr_s_e.sql
  • Execute the command ant setup
  • Execute the command ant update-database

Architecture

Somda is built in the Symfony framework with an MVC architecture.

Database

The basic layout of the database origins in 2004. Therefore, the design is not that modern at some points. It is on the todo-list to improve that. New tables in the database should already comply with the guidelines as described below, existing tables will be changed.

  • Each table starts with a 3 character abbreviation.
  • This abbreviation is short for the rest of the table name:
    • If the table name is 1 word, the first 3 characters are used. For example sys_system.
    • If the table name is 2 words, the first 2 characters of the first word are used followed by the first character of the second word. For example: usp_user_preference.
    • If the table name is 3 or more words, the first character of the first 3 words is used. For example spd_system_preference_domain.
  • This abbreviation is also prefixed in all columns.
  • In a column with a foreign key, the abbreviation of the other table is used. For example if usp_user_preference has a column with a foreign key to column id of table pre_preference, that column is named usp_pre_id.

Code

Somda uses a Model - View - Controller architecture following these guidelines:

  • Models have no knowledge of each other and contain only functions that require no knowledge of the outside world. For a good example, look at isActive in Entity\TrainTableYear.
  • Views contain as little business logic as possible, they basically only display what the controllers give them.
  • Controllers contain as little business logic as possible, they only process forms, collect data and hand data to the views. If you need business logic, consider a helper or service.

Unit-testing

To start running unit tests, execute the following steps:

  • Copy phpunit.xml.dist in the root to phpunit.xml.
  • Adjust the value for DATABASE_URL to your needs, this should be a separate database from your local environment.
  • Execute bin/phpunit
  • Execute php composer.phar dump-env test Now you can execute the unit tests with the use of phpunit.xml.

Contributing

Somda is not the best code out there. Some of the principles as described are not followed or only halfway. With each update there will be refactoring to make things better. If you decide to contribute, please make better code than what you found...

Pull-requests at Github are highly encouraged and will always be reviewed and considered. Please always base them on the develop branch.

somda2's People

Contributors

dependabot[bot] avatar pvdleek avatar rensbloom avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

rensbloom

somda2's Issues

Use translations in all templates and code

A lot of templates and some of the controllers, helpers and maybe even models contain hardcoded Dutch language strings. They all need to be moved to translation-files so we can think about incorporating other languages.

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.