Giter Site home page Giter Site logo

guardian-craftcms's Introduction

News Project

This codebase is a demonstration of my PHP capabilities, specifically within the Craft CMS / Yii frameworks.

I have focused on the back-end component of this project. My progress so far:

  • Create API proxy, specifically for The Guardian, but scaffolded for multiple providers
  • Normalise returned content into a consistent model
  • Apply data caching to improve performance of repeat requests

Next steps / considerations:

  • Under what circumstances (beyond expiry) should the cache be cleared (live blogs?)
  • Pagination? How does this work with multiple end points?
  • Storage of pinned articles: use session storage for guests, convert to user field?
  • Allow front-end registration / login / forgot password.
  • Do we want to store article metadata in the CMS? If so, we could use the Wishlist plugin.
  • Are articles ever removed from an API? How does this affect pinned articles?
  • Do we ever need to return the full article and display it?
  • There are so many news APIs!

This project provided the opportunity to dig into:

  • ๐Ÿ”Œ Modules! They're like plugins, but a bit different
  • ๐Ÿชต Logging! Now I know how to register my own log file, which is tidy.
  • ๐ŸŒ† Models! Craft intends you to create models and records in tandem, but they're useful on their own.
  • ๐Ÿงณ Caching! I'd used this before, but it's good to practice.
  • ๐Ÿ†Ž Types! I'm learning TypeScript, and I have a better understanding of how to type my PHP.

Using this Craft CMS project in local dev

  1. Have Docker Desktop installed
  2. Clone your newly created repo down to your computer
  3. cd to your repo in your terminal
  4. Get the project up and running with make dev
  5. Wait until you see output like this, and then access the site via the credentials that are output on the console:
spin-up-craft-queue-1  | ### Your Craft site is ready!
spin-up-craft-queue-1  | Frontend URL: http://localhost:8050/
spin-up-craft-queue-1  | CP URL: http://localhost:8050/admin
spin-up-craft-queue-1  | CP User: admin
spin-up-craft-queue-1  | CP Password: project

Hit Control-C to terminate the project and spin down the containers

The first time you start up your project, it'll take some time to set everything up. However, subsequent startups will be very quick.

Visit the news controller to see the returned data!

Available make commands

This project uses make to execute various commands in the appropriate containers. Here's a list of available commands:

  • make dev - Start the dev server
  • make composer xxx - Execute a composer command in the PHP container
  • make craft xxx - Execute a craft CLI command in the PHP container
  • make ssh - Open up a shell in the PHP container
  • make db-admin-reset - Reset the admin (user with the ID=1) to the defaults in from the .env file; useful after importing a foreign database
  • make db-export - Clean the db-seed/ directory and export the database to it
  • make db-import - Import the db from db-seed/ directory into the mysql container

If the project is already running via make dev you can use a second terminal tab/window to execute additional commands.

Random notes

  • The .env file is created by copying example.env file when you start the project up
  • The server will use the INITIAL_SERVER_PORT in the .env file for the initial port to start looking for unused ports from. It will increment it until it finds and unused port, and then use it
  • If instead you want to used a fixed port, you can explicitly set the DEV_SERVER_PORT in the .env file
  • The Docker containers will be named after the project directory, so give it a unique name for each project

Credits

Forked from Spin Up Craft by nystudio107

guardian-craftcms's People

Contributors

kashkin avatar

Watchers

 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.