Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 4 Playground
#21

(11-27-2019, 07:50 AM)MGatner Wrote: We have LOTS to add, but if anyone has requests for examples they would like to see implemented this would be a good place to ask.

Big Grin

It would be nice to see some testing examples ! Controller testing...


Heart Heart Heart

Specially using the HTTP feature...
Reply
#22

(11-27-2019, 08:06 PM)John_Betong Wrote: @includebeer

I followed the additional playground/README.md instructions.

Composer downloaded lots of files, I set the .env->Database with relevant login details and still failed Sad

@MGatner
The GitHub README.md file was not copied and pasted accurately.

Some of the instructions are not crystal clear Sad

cd playground composer install

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

php spark migrate php spark dbConfusedeed PlaygroundSeeder

Are you experiencing errors? If so, can you paste them here?

(Using CodeIgniter since 1.x)
Reply
#23

Thanks for what seems to be a brilliant initiative!

However, I'm a little confused at the moment. I have everything installed but cannot see any code other than App/Models/HeroModel.php and what's in the tests directory that isn't part of the base CI installation.

What am I missing here?

Cheers,

Jim
Reply
#24

@jimpannell your assessment is correct! Though don’t overlook the docs folder with some very helpful info supplemental to the User Guide. This is a work-in-progress, just launched and still very young. People have had a lot of requests which is great, and we hope to add them (or take community PRs!) as we go, but there is still much to be done.
Reply
#25

(11-27-2019, 08:13 PM)jasonzig Wrote:
(11-27-2019, 08:06 PM)John_Betong Wrote: @includebeer

I followed the additional playground/README.md instructions.

Composer downloaded lots of files, I set the .env->Database with relevant login details and still failed Sad

@MGatner
The GitHub README.md file was not copied and pasted accurately.

Some of the instructions are not crystal clear Sad

cd playground composer install

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

php spark migrate php spark dbConfusedeed PlaygroundSeeder

Are you experiencing errors? If so, can you paste them here?

// Errors after setting .env:  
   john@john:/var/www/ci2/playground$ sudo php spark migrate
   CodeIgniter CLI Tool - Version 4.0.0-rc.3 - Server-Time: 2019-11-28 22:17:13pm
   Running all new migrations...
   Access denied for user '****'@localhost (using password: YES)
   /var/www/ci2/CodeIgniter4/system/Database/MySQLi/Connection.php - 225

// TRY AGAIN AND SETTING /App/config/Database.php
   john@john:/var/www/ci2/playground$ sudo php spark migrate
   CodeIgniter CLI Tool - Version 4.0.0-rc.3 - Server-Time: 2019-11-28 22:17:37pm
   Running all new migrations...
   Unknown database '../writable/database.db'
   /var/www/ci2/CodeIgniter4/system/Database/MySQLi/Connection.php - 225

Hope the above errors are useful.
Reply
#26

@John_Betong in your first example it’s a straight MySQL credentials issue. Make sure you can connect to the database from the command line with whatever credentials you are using before trying it in CI4.

In the second example it looks like you didn’t remove the “database” line from .env when you set it in the config files, so even though you are using MySQL it is still looking for the database named for SQLite. Try removing that from .env and running again.
Reply
#27

(11-29-2019, 05:14 AM)MGatner Wrote: @John_Betong in your first example it’s a straight MySQL credentials issue. Make sure you can connect to the database from the command line with whatever credentials you are using before trying it in CI4.

In the second example it looks like you didn’t remove the “database” line from .env when you set it in the config files, so even though you are using MySQL it is still looking for the database named for SQLite. Try removing that from .env and running again.
Many thanks that got me over that hurdle Smile

I removed .env and also had to add the following:
PHP Code:
./app/Config/Database.php -> public $default = [
...
  'database' 'ci4',
...
]; 

Next hurdle with setting the following in index.php:
PHP Code:
# John
  define('CI_DEBUG'TRUE); 
  $_SERVER['CI_ENVIRONMENT'] = 'development'
Welcome_message appeared OK but  the following errors were logged:
PHP Code:
CRITICAL 2019-11-29 08:21:23 --> Undefined propertyConfig\App::$CSRFHeaderName
#0 /var/www/ci2/CodeIgniter4/system/Security/Security.php(184): CodeIgniter\Debug\Exceptions->errorHandler(8, 'Undefined prope...', '/var/www/ci2/Co...', 184, Array)
#1 /var/www/ci2/CodeIgniter4/system/Config/Services.php(738): CodeIgniter\Security\Security->__construct(Object(Config\App))
#2 /var/www/ci2/CodeIgniter4/system/Config/BaseService.php(120): CodeIgniter\Config\Services::security(Object(Config\App), false)
#3 /var/www/ci2/CodeIgniter4/system/Config/Services.php(730): CodeIgniter\Config\BaseService::getSharedInstance('security', NULL)
#4 /var/www/ci2/CodeIgniter4/system/Helpers/security_helper.php(59): CodeIgniter\Config\Services::security()
#5 /var/www/ci2/CodeIgniter4/system/Debug/Toolbar.php(448): sanitize_filename('debugbar_157503...')
#6 /var/www/ci2/playground/app/Config/Events.php(41): CodeIgniter\Debug\Toolbar->respond()
#7 [internal function]: CodeIgniter\Events\Events::Config\{closure}()
#8 /var/www/ci2/CodeIgniter4/system/Events/Events.php(188): call_user_func(Object(Closure))
#9 /var/www/ci2/CodeIgniter4/system/CodeIgniter.php(227): CodeIgniter\Events\Events::trigger('pre_system')
#10 /var/www/ci2/playground/public/index.php(54): CodeIgniter\CodeIgniter->run()
#11 {main} 

These errors were generated when using my modified ci4-strict.tk/system files:
PHP Code:
CRITICAL 2019-11-29 08:26:58 --> Undefined propertyConfig\App::$CSRFHeaderName
#0 /var/www/ci4-strict.tk/system/Security/Security.php(185): CodeIgniter\Debug\Exceptions->errorHandler(8, 'Undefined prope...', '/var/www/ci4-st...', 185, Array)
#1 /var/www/ci4-strict.tk/system/Config/Services.php(739): CodeIgniter\Security\Security->__construct(Object(Config\App))
#2 /var/www/ci4-strict.tk/system/Config/BaseService.php(121): CodeIgniter\Config\Services::security(Object(Config\App), false)
#3 /var/www/ci4-strict.tk/system/Config/Services.php(731): CodeIgniter\Config\BaseService::getSharedInstance('security', NULL)
#4 /var/www/ci4-strict.tk/system/Helpers/security_helper.php(60): CodeIgniter\Config\Services::security()
#5 /var/www/ci4-strict.tk/system/Debug/Toolbar.php(449): sanitize_filename('debugbar_157503...')
#6 /var/www/ci2/playground/app/Config/Events.php(41): CodeIgniter\Debug\Toolbar->respond()
#7 [internal function]: CodeIgniter\Events\Events::Config\{closure}()
#8 /var/www/ci4-strict.tk/system/Events/Events.php(189): call_user_func(Object(Closure))
#9 /var/www/ci4-strict.tk/system/CodeIgniter.php(228): CodeIgniter\Events\Events::trigger('pre_system')
#10 /var/www/ci2/playground/public/index.php(54): CodeIgniter\CodeIgniter->run()
#11 {main} 

Please let me know if there is any further information required.
Reply
#28

(This post was last modified: 11-29-2019, 07:40 AM by MGatner.)

This is a known issue with the app/ folder being from an older version. I have a pull request to fix it (https://github.com/codeigniter4projects/...und/pull/8), I will see if I can get that in.

Just to warn you, Playground won't necessarily work with a modified version of system. That's a great way to "play" with the framework but you will likely need to make changes to the app itself as well.

@John_Betong Okay that is merged, try pulling the latest version of Playground and see if you have better luck.
Reply
#29

(This post was last modified: 12-01-2019, 04:48 AM by triluminos.)

Thank you CI Team. Great job.
There is a problem. in playground repository it seems that there is not any system directory. therefore we should copy it manually from 'vendor\codeigniter4\codeigniter4'
Best regards
Reply
#30

@triluminos That’s intentional! Playground is an example of project distribution using Composer for installation. From the README:

While CodeIgniter does not require it, using this repo also requires the use of Composer to install CodeIgniter as a dependency

When you run “composer install” it will download the framework into the appropriate directory. This allows Playground to be distributed independent of a specific version of the framework. If you want to use Playground (or other CI4 apps) without Composer you may but you will need to download the framework separately and update the Paths.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB