'
102 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2019 British Columbia Institute of Technology
4 | Copyright (c) 2019-2020 CodeIgniter Foundation
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests
15 |
16 |
17 |
18 |
19 |
20 | ./app
21 |
22 | ./app/Views
23 | ./app/Config/Routes.php
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 | # Disable directory browsing
2 | Options All -Indexes
3 |
4 | # ----------------------------------------------------------------------
5 | # Rewrite engine
6 | # ----------------------------------------------------------------------
7 |
8 | # Turning on the rewrite engine is necessary for the following rules and features.
9 | # FollowSymLinks must be enabled for this to work.
10 |
11 | Options +FollowSymlinks
12 | RewriteEngine On
13 |
14 | # If you installed CodeIgniter in a subfolder, you will need to
15 | # change the following line to match the subfolder you need.
16 | # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
17 | # RewriteBase /
18 |
19 | # Redirect Trailing Slashes...
20 | RewriteCond %{REQUEST_FILENAME} !-d
21 | RewriteRule ^(.*)/$ /$1 [L,R=301]
22 |
23 | # Rewrite "www.example.com -> example.com"
24 | RewriteCond %{HTTPS} !=on
25 | RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
26 | RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
27 |
28 | # Checks to see if the user is attempting to access a valid file,
29 | # such as an image or css document, if this isn't true it sends the
30 | # request to the front controller, index.php
31 | RewriteCond %{REQUEST_FILENAME} !-f
32 | RewriteCond %{REQUEST_FILENAME} !-d
33 | RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
34 |
35 | # Ensure Authorization header is passed along
36 | RewriteCond %{HTTP:Authorization} .
37 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
38 |
39 |
40 |
41 | # If we don't have mod_rewrite installed, all 404's
42 | # can be sent to index.php, and everything works as normal.
43 | ErrorDocument 404 index.php
44 |
45 |
46 | # Disable server signature start
47 | ServerSignature Off
48 | # Disable server signature end
49 |
--------------------------------------------------------------------------------
/public/assets/demo/chart-area-demo.js:
--------------------------------------------------------------------------------
1 | // Set new default font family and font color to mimic Bootstrap's default styling
2 | Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
3 | Chart.defaults.global.defaultFontColor = '#292b2c';
4 |
5 | // Area Chart Example
6 | var ctx = document.getElementById("myAreaChart");
7 | var myLineChart = new Chart(ctx, {
8 | type: 'line',
9 | data: {
10 | labels: ["Mar 1", "Mar 2", "Mar 3", "Mar 4", "Mar 5", "Mar 6", "Mar 7", "Mar 8", "Mar 9", "Mar 10", "Mar 11", "Mar 12", "Mar 13"],
11 | datasets: [{
12 | label: "Sessions",
13 | lineTension: 0.3,
14 | backgroundColor: "rgba(2,117,216,0.2)",
15 | borderColor: "rgba(2,117,216,1)",
16 | pointRadius: 5,
17 | pointBackgroundColor: "rgba(2,117,216,1)",
18 | pointBorderColor: "rgba(255,255,255,0.8)",
19 | pointHoverRadius: 5,
20 | pointHoverBackgroundColor: "rgba(2,117,216,1)",
21 | pointHitRadius: 50,
22 | pointBorderWidth: 2,
23 | data: [10000, 30162, 26263, 18394, 18287, 28682, 31274, 33259, 25849, 24159, 32651, 31984, 38451],
24 | }],
25 | },
26 | options: {
27 | scales: {
28 | xAxes: [{
29 | time: {
30 | unit: 'date'
31 | },
32 | gridLines: {
33 | display: false
34 | },
35 | ticks: {
36 | maxTicksLimit: 7
37 | }
38 | }],
39 | yAxes: [{
40 | ticks: {
41 | min: 0,
42 | max: 40000,
43 | maxTicksLimit: 5
44 | },
45 | gridLines: {
46 | color: "rgba(0, 0, 0, .125)",
47 | }
48 | }],
49 | },
50 | legend: {
51 | display: false
52 | }
53 | }
54 | });
55 |
--------------------------------------------------------------------------------
/public/assets/demo/chart-bar-demo.js:
--------------------------------------------------------------------------------
1 | // Set new default font family and font color to mimic Bootstrap's default styling
2 | Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
3 | Chart.defaults.global.defaultFontColor = '#292b2c';
4 |
5 | // Bar Chart Example
6 | var ctx = document.getElementById("myBarChart");
7 | var myLineChart = new Chart(ctx, {
8 | type: 'bar',
9 | data: {
10 | labels: ["January", "February", "March", "April", "May", "June"],
11 | datasets: [{
12 | label: "Revenue",
13 | backgroundColor: "rgba(2,117,216,1)",
14 | borderColor: "rgba(2,117,216,1)",
15 | data: [4215, 5312, 6251, 7841, 9821, 14984],
16 | }],
17 | },
18 | options: {
19 | scales: {
20 | xAxes: [{
21 | time: {
22 | unit: 'month'
23 | },
24 | gridLines: {
25 | display: false
26 | },
27 | ticks: {
28 | maxTicksLimit: 6
29 | }
30 | }],
31 | yAxes: [{
32 | ticks: {
33 | min: 0,
34 | max: 15000,
35 | maxTicksLimit: 5
36 | },
37 | gridLines: {
38 | display: true
39 | }
40 | }],
41 | },
42 | legend: {
43 | display: false
44 | }
45 | }
46 | });
47 |
--------------------------------------------------------------------------------
/public/assets/demo/chart-pie-demo.js:
--------------------------------------------------------------------------------
1 | // Set new default font family and font color to mimic Bootstrap's default styling
2 | Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
3 | Chart.defaults.global.defaultFontColor = '#292b2c';
4 |
5 | // Pie Chart Example
6 | var ctx = document.getElementById("myPieChart");
7 | var myPieChart = new Chart(ctx, {
8 | type: 'pie',
9 | data: {
10 | labels: ["Blue", "Red", "Yellow", "Green"],
11 | datasets: [{
12 | data: [12.21, 15.58, 11.25, 8.32],
13 | backgroundColor: ['#007bff', '#dc3545', '#ffc107', '#28a745'],
14 | }],
15 | },
16 | });
17 |
--------------------------------------------------------------------------------
/public/assets/demo/datatables-demo.js:
--------------------------------------------------------------------------------
1 | // Call the dataTables jQuery plugin
2 | $(document).ready(function() {
3 | $('#dataTable').DataTable();
4 | });
5 |
--------------------------------------------------------------------------------
/public/assets/img/error-404-monochrome.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilhamlutfi/starter-ci4/98deac173b2b385de749d22a899bbbb9c84a021d/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 | systemDirectory, '/ ') . '/bootstrap.php';
37 |
38 | /*
39 | *---------------------------------------------------------------
40 | * LAUNCH THE APPLICATION
41 | *---------------------------------------------------------------
42 | * Now that everything is setup, it's time to actually fire
43 | * up the engines and make this app do its thang.
44 | */
45 | $app->run();
46 |
--------------------------------------------------------------------------------
/public/js/scripts.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Start Bootstrap - SB Admin v6.0.1 (https://startbootstrap.com/templates/sb-admin)
3 | * Copyright 2013-2020 Start Bootstrap
4 | * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE)
5 | */
6 | (function($) {
7 | "use strict";
8 |
9 | // Add active state to sidbar nav links
10 | var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
11 | $("#layoutSidenav_nav .sb-sidenav a.nav-link").each(function() {
12 | if (this.href === path) {
13 | $(this).addClass("active");
14 | }
15 | });
16 |
17 | // Toggle the side navigation
18 | $("#sidebarToggle").on("click", function(e) {
19 | e.preventDefault();
20 | $("body").toggleClass("sb-sidenav-toggled");
21 | });
22 | })(jQuery);
23 |
--------------------------------------------------------------------------------
/public/photos/1609652617_aefcf01489903d3b1a03.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilhamlutfi/starter-ci4/98deac173b2b385de749d22a899bbbb9c84a021d/public/photos/1609652617_aefcf01489903d3b1a03.jpeg
--------------------------------------------------------------------------------
/public/photos/1609654226_b43f308ecb2f7d206226.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilhamlutfi/starter-ci4/98deac173b2b385de749d22a899bbbb9c84a021d/public/photos/1609654226_b43f308ecb2f7d206226.jpeg
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/spark:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | systemDirectory, '/ ') . '/bootstrap.php';
45 |
46 | // Grab our Console
47 | $console = new \CodeIgniter\CLI\Console($app);
48 |
49 | // We want errors to be shown when using it from the CLI.
50 | error_reporting(-1);
51 | ini_set('display_errors', 1);
52 |
53 | // Show basic information before we do anything else.
54 | $console->showHeader();
55 |
56 | // fire off the command in the main framework.
57 | $response = $console->run();
58 | if ($response->getStatusCode() >= 300)
59 | {
60 | exit($response->getStatusCode());
61 | }
62 |
--------------------------------------------------------------------------------
/tests/README.md:
--------------------------------------------------------------------------------
1 | # Running Application Tests
2 |
3 | This is the quick-start to CodeIgniter testing. Its intent is to describe what
4 | it takes to set up your application and get it ready to run unit tests.
5 | It is not intended to be a full description of the test features that you can
6 | use to test your application. Those details can be found in the documentation.
7 |
8 | ## Resources
9 | * [CodeIgniter 4 User Guide on Testing](https://codeigniter4.github.io/userguide/testing/index.html)
10 | * [PHPUnit docs](https://phpunit.readthedocs.io/en/8.3/index.html)
11 |
12 | ## Requirements
13 |
14 | It is recommended to use the latest version of PHPUnit. At the time of this
15 | writing we are running version 8.5.2. Support for this has been built into the
16 | **composer.json** file that ships with CodeIgniter and can easily be installed
17 | via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
18 |
19 | > composer install
20 |
21 | If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer.
22 |
23 | > ln -s ./vendor/bin/phpunit ./phpunit
24 |
25 | You also need to install [XDebug](https://xdebug.org/index.php) in order
26 | for code coverage to be calculated successfully.
27 |
28 | ## Setting Up
29 |
30 | A number of the tests use a running database.
31 | In order to set up the database edit the details for the `tests` group in
32 | **app/Config/Database.php** or **phpunit.xml**. Make sure that you provide a database engine
33 | that is currently running on your machine. More details on a test database setup are in the
34 | *Docs>>Testing>>Testing Your Database* section of the documentation.
35 |
36 | If you want to run the tests without using live database you can
37 | exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml** -
38 | call it **phpunit.xml** - and comment out the named "database". This will make
39 | the tests run quite a bit faster.
40 |
41 | ## Running the tests
42 |
43 | The entire test suite can be run by simply typing one command-line command from the main directory.
44 |
45 | > ./phpunit
46 |
47 | You can limit tests to those within a single test directory by specifying the
48 | directory name after phpunit.
49 |
50 | > ./phpunit app/Models
51 |
52 | ## Generating Code Coverage
53 |
54 | To generate coverage information, including HTML reports you can view in your browser,
55 | you can use the following command:
56 |
57 | > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
58 |
59 | This runs all of the tests again collecting information about how many lines,
60 | functions, and files are tested. It also reports the percentage of the code that is covered by tests.
61 | It is collected in two formats: a simple text file that provides an overview as well
62 | as a comprehensive collection of HTML files that show the status of every line of code in the project.
63 |
64 | The text file can be found at **tests/coverage.txt**.
65 | The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser.
66 |
67 | ## PHPUnit XML Configuration
68 |
69 | The repository has a ``phpunit.xml.dist`` file in the project root that's used for
70 | PHPUnit configuration. This is used to provide a default configuration if you
71 | do not have your own configuration file in the project root.
72 |
73 | The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml``
74 | (which is git ignored), and to tailor it as you see fit.
75 | For instance, you might wish to exclude database tests, or automatically generate
76 | HTML code coverage reports.
77 |
78 | ## Test Cases
79 |
80 | Every test needs a *test case*, or class that your tests extend. CodeIgniter 4
81 | provides a few that you may use directly:
82 | * `CodeIgniter\Test\CIUnitTestCase` - for basic tests with no other service needs
83 | * `CodeIgniter\Test\CIDatabaseTestCase` - for tests that need database access
84 |
85 | Most of the time you will want to write your own test cases to hold functions and services
86 | common to your test suites.
87 |
88 | ## Creating Tests
89 |
90 | All tests go in the **tests/** directory. Each test file is a class that extends a
91 | **Test Case** (see above) and contains methods for the individual tests. These method
92 | names must start with the word "test" and should have descriptive names for precisely what
93 | they are testing:
94 | `testUserCanModifyFile()` `testOutputColorMatchesInput()` `testIsLoggedInFailsWithInvalidUser()`
95 |
96 | Writing tests is an art, and there are many resources available to help learn how.
97 | Review the links above and always pay attention to your code coverage.
98 |
99 | ### Database Tests
100 |
101 | Tests can include migrating, seeding, and testing against a mock or live1 database.
102 | Be sure to modify the test case (or create your own) to point to your seed and migrations
103 | and include any additional steps to be run before tests in the `setUp()` method.
104 |
105 | 1 Note: If you are using database tests that require a live database connection
106 | you will need to rename **phpunit.xml.dist** to **phpunit.xml**, uncomment the database
107 | configuration lines and add your connection details. Prevent **phpunit.xml** from being
108 | tracked in your repo by adding it to **.gitignore**.
109 |
--------------------------------------------------------------------------------
/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php:
--------------------------------------------------------------------------------
1 | [
13 | 'type' => 'varchar',
14 | 'constraint' => 31,
15 | ],
16 | 'uid' => [
17 | 'type' => 'varchar',
18 | 'constraint' => 31,
19 | ],
20 | 'class' => [
21 | 'type' => 'varchar',
22 | 'constraint' => 63,
23 | ],
24 | 'icon' => [
25 | 'type' => 'varchar',
26 | 'constraint' => 31,
27 | ],
28 | 'summary' => [
29 | 'type' => 'varchar',
30 | 'constraint' => 255,
31 | ],
32 | 'created_at' => [
33 | 'type' => 'datetime',
34 | 'null' => true,
35 | ],
36 | 'updated_at' => [
37 | 'type' => 'datetime',
38 | 'null' => true,
39 | ],
40 | 'deleted_at' => [
41 | 'type' => 'datetime',
42 | 'null' => true,
43 | ],
44 | ];
45 |
46 | $this->forge->addField('id');
47 | $this->forge->addField($fields);
48 |
49 | $this->forge->addKey('name');
50 | $this->forge->addKey('uid');
51 | $this->forge->addKey(['deleted_at', 'id']);
52 | $this->forge->addKey('created_at');
53 |
54 | $this->forge->createTable('factories');
55 | }
56 |
57 | public function down()
58 | {
59 | $this->forge->dropTable('factories');
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/tests/_support/Database/Seeds/ExampleSeeder.php:
--------------------------------------------------------------------------------
1 | 'Test Factory',
12 | 'uid' => 'test001',
13 | 'class' => 'Factories\Tests\NewFactory',
14 | 'icon' => 'fas fa-puzzle-piece',
15 | 'summary' => 'Longer sample text for testing',
16 | ],
17 | [
18 | 'name' => 'Widget Factory',
19 | 'uid' => 'widget',
20 | 'class' => 'Factories\Tests\WidgetPlant',
21 | 'icon' => 'fas fa-puzzle-piece',
22 | 'summary' => 'Create widgets in your factory',
23 | ],
24 | [
25 | 'name' => 'Evil Factory',
26 | 'uid' => 'evil-maker',
27 | 'class' => 'Factories\Evil\MyFactory',
28 | 'icon' => 'fas fa-book-dead',
29 | 'summary' => 'Abandon all hope, ye who enter here',
30 | ],
31 | ];
32 |
33 | $builder = $this->db->table('factories');
34 |
35 | foreach ($factories as $factory)
36 | {
37 | $builder->insert($factory);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/tests/_support/DatabaseTestCase.php:
--------------------------------------------------------------------------------
1 | mockSession();
19 | }
20 |
21 | /**
22 | * Pre-loads the mock session driver into $this->session.
23 | *
24 | * @var string
25 | */
26 | protected function mockSession()
27 | {
28 | $config = config('App');
29 | $this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config);
30 | \Config\Services::injectMock('session', $this->session);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tests/database/ExampleDatabaseTest.php:
--------------------------------------------------------------------------------
1 | findAll();
20 |
21 | // Make sure the count is as expected
22 | $this->assertCount(3, $objects);
23 | }
24 |
25 | public function testSoftDeleteLeavesRow()
26 | {
27 | $model = new ExampleModel();
28 | $this->setPrivateProperty($model, 'useSoftDeletes', true);
29 | $this->setPrivateProperty($model, 'tempUseSoftDeletes', true);
30 |
31 | $object = $model->first();
32 | $model->delete($object->id);
33 |
34 | // The model should no longer find it
35 | $this->assertNull($model->find($object->id));
36 |
37 | // ... but it should still be in the database
38 | $result = $model->builder()->where('id', $object->id)->get()->getResult();
39 |
40 | $this->assertCount(1, $result);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tests/session/ExampleSessionTest.php:
--------------------------------------------------------------------------------
1 | session->set('logged_in', 123);
13 |
14 | $value = $this->session->get('logged_in');
15 |
16 | $this->assertEquals(123, $value);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tests/unit/HealthTest.php:
--------------------------------------------------------------------------------
1 | assertTrue($test);
15 | }
16 |
17 | public function testBaseUrlHasBeenSet()
18 | {
19 | $env = $config = false;
20 |
21 | // First check in .env
22 | if (is_file(HOMEPATH . '.env'))
23 | {
24 | $env = (bool) preg_grep("/^app\.baseURL = './", file(HOMEPATH . '.env'));
25 | }
26 |
27 | // Then check the actual config file
28 | $reader = new \Tests\Support\Libraries\ConfigReader();
29 | $config = ! empty($reader->baseUrl);
30 |
31 | $this->assertTrue($env || $config);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/writable/.htaccess:
--------------------------------------------------------------------------------
1 |
2 | Require all denied
3 |
4 |
5 | Deny from all
6 |
7 |
--------------------------------------------------------------------------------
/writable/cache/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 403 Forbidden
5 |
6 |
7 |
8 |