Hello
Im trying to make a switch from CI3 to CI4. I must admit that I really like ci3, however ci4 looks great and I'm looking forward to make an apps with new version o ci.
At the beginning, for the testing purspose, I'm trying to write a really simple auth libarary. In CI3 i would create MyAuth in application/library:
PHP Code:
class MyAuth
{
...
public function getName(){
return $this->firstName.' '.$this->lastName;
}
in controller i could load it
PHP Code:
public function testing
{
$this->load->library('myauth');
return view('file',$this->outputData);
}
and in view I could print it like that:
PHP Code:
echo $this->myauth->getName();
Is there any way to do the same in ci 4?
Sorry but I can't find many informations about creating libraries in CI 4.
Second question:
How to check if there's database connection?
In CI 3 i checked it this way:
PHP Code:
$connDB = $this->load->database('default',TRUE);
if(! $connDB->conn_id){
//redirect to static page
}
In ci 4 when im'trying
PHP Code:
$this->dbSocket = \Config\Database::connect($custom);
dbSocket->connID is always false.