Giter Club home page Giter Club logo

playground's Introduction

Playground

A space to learn and experience CodeIgniter 4

This playground is here to help you learn CodeIgniter 4 by example. We try to cover use cases for the most common tasks you'll find yourself doing in web applications. Where there are multiple ways to do something, we've tried to give examples of doing things in each way.

This isn't meant to replace the docs. This is just something to look at to get a deeper understanding, or to better see how something could be done in practice.

Resources

There are two primary ways to learn about what's going on here in the Playground. The first is the code itself. We've heaped a LOT of comments throughout the code. They're your best docs. So explore them in depth. Additionally, there's a small collection of docs in the conveniently named docs folder.

To setup a working playground on your own local device, read through the next section.

Getting Started

In order to get the playground setup on your own computer, you'll need a few minimum requirements - all of which are listed on CodeIgniter's repo. Basically, as long as you are running PHP 7.2 or later you'll meet most of them.

While CodeIgniter does not require it, using this repo also requires the use of Composer to install CodeIgniter as a dependency, and PHPUnit - the test framework. You don't need that installed globally, and we actually recommend against it, since different projects likely require different versions of PHPUnit installed as time goes on and it can become tricky maintain a local environment that works with all of the different versions.

While it can be downloaded as a zip and extracted, we'll use git to manage things.

With those out of the way, it only takes a few small steps to get the project up and running locally.

1 - Clone the repo if you haven't already, from the CLI:

git clone https://github.com/codeigniter4projects/playground

That creates a new directory, playground, under your current directory.

2 - Enter the new directory and install the project dependencies with Composer. NOTE: The command shown here assumes that you have Composer loaded globally. If you don't, then pretend we're using composer.phar.

cd playground composer install

3 - Copy .env.example in the project directory and name it .env. Then open it up and make a couple of edits:

CI_ENVIRONMENT = development app.baseURL = 'http://localhost:8080/'

First we uncommented the CI_ENVIRONMENT line and changed production to development. This enables error handling, the debug toolbar, and some other things handy while in development.

Next, make sure that app.baseURL matches whatever you are currently running your site at. If you use spark, then it already matches the default. If this doesn't match, then generated links might not work, and your developer toolbar will never show up.

While you're in there, you can edit your database settings, though you can do that in app/Config/Database.php just as easily. Since we won't deploy this to multiple servers it's no big deal to edit the config files directly.

4 - Back on the command line, we install all of the needed database tables and sample data.

php spark migrate php spark db:seed PlaygroundSeeder

5 - That's it! If you're hosting through Apache, Nginx, etc, then head to your site. If you just want a quick way to work with your site locally, go back to the CLI and start up spark, CodeIgniter's small server.

php spark serve

If you get would like to change the port it's running on, that's no problem:

php spark serve --port 8081

Enjoy!

playground's People

Contributors

mgatner avatar lonnieezell avatar jim-parry avatar

Watchers

James Cloos 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.