CodeIgniter Forums
how create an self installing project - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: how create an self installing project (/showthread.php?tid=74902)



how create an self installing project - pippuccio76 - 11-23-2019

Hi , sorry for english , i want create a project in codeigniter self installing , the problem is f.e. the db setting  .
There is a guide how to create a sel installing project ?


RE: how create an self installing project - mewein - 11-23-2019

You should check the documentation of codeigniter for help but just to give you a quick start ill explain how to create your first codeigniter project.
Installation
1 Download the codeigniter framework
2 upload it in root directory of your website or local apache server directory.
Creating your codeigniter project. In codeigniter your controller will handle the url requests and load appropriate model and views. So the first step is to create your controller.

1 Creating your controller: go to Applications->controllers and there you will find a built in controller called welcome.php. This controller loads a view welcome_message.php which is inside Application->views. You can use this controller or create your own. To create your own controller create a new php file myfirstcontroller.php and extend a class with same name from CI_Controller. Note that the name of the file and your class name should be the same. the index function is the default function that will be called when you make a request to the controller
class myfirstcontroller extends CI_Controller {

public function index(){

$this->load->view("myfirstview");

}

}
so when you request this controller through yoursite/index.php/myfirstcontroller

it will load a view called myfirstview.php which will reside inside applications->views.

Go ahead and create this file in applications ->views.

2 To pass data from controller to view you will send an array to the view
class myfirstcontroller extends CI_Controller {

public function index(){

$data['name']="My first application.";
$this->load->view("myfirstview",$data);

}

}
3 You can access this variable in view
echo $name
and it will output your variable

3 you use models you have to create a file inside applications->models and call it from controller and it will return the result in the form of array.

You can look at the documentation for further help.

Hope this helped you to get started with codeigniter.

The user guide is inside your download library.
Good luck!!!


RE: how create an self installing project - pippuccio76 - 01-19-2020

(11-23-2019, 09:00 AM)mewein Wrote: You should check the documentation of codeigniter for help but just to give you a quick start ill explain how to create your first codeigniter project.
Installation
1 Download the codeigniter framework
2 upload it in root directory of your website or local apache server directory.
Creating your codeigniter project. In codeigniter your controller will handle the url requests and load appropriate model and views. So the first step is to create your controller.

1 Creating your controller: go to Applications->controllers and there you will find a built in controller called welcome.php. This controller loads a view welcome_message.php which is inside Application->views. You can use this controller or create your own. To create your own controller create a new php file myfirstcontroller.php and extend a class with same name from CI_Controller. Note that the name of the file and your class name should be the same. the index function is the default function that will be called when you make a request to the controller
class myfirstcontroller extends CI_Controller {

    public function index(){

    $this->load->view("myfirstview");

    }

}
so when you request this controller through yoursite/index.php/myfirstcontroller

it will load a view called myfirstview.php which will reside inside applications->views.

Go ahead and create this file in applications ->views.

2 To pass data from controller to view you will send an array to the view
class myfirstcontroller extends CI_Controller {

    public function index(){

    $data['name']="My first application.";
    $this->load->view("myfirstview",$data);

    }

}
3 You can access this variable in view
  echo $name
and it will output your variable

3 you use models you have to create a file inside applications->models and call it from controller and it will return the result in the form of array.

You can look at the documentation for further help.

Hope this helped you to get started with codeigniter.

The user guide is inside your download library.
Good luck!!!

You dont understand me , i use codeigniter for my project ...

I can create an entire db by visit a page ,but  the answer is how can i set the db credential automatically in config->database or how can i semplify this process for user ? If i want create a csm how can user simply insert base_url and db credential without insert they in  config (in config  and database) ?


RE: how create an self installing project - John_Betong - 01-19-2020

@pippuccio76,
> can create an entire db by visit a page ,but the answer is how can i set the db credential automatically in config->database or how can i semplify this process for user ? If i want create a csm how can user simply insert base_url and db credential without insert they in config (in config and database) ?

Check the Github link in my signature, download there zip or clone the repository and see if the installation satisfies your requirements. Please report back if you have any problems.


RE: how create an self installing project - jreklund - 01-19-2020

(01-19-2020, 04:14 AM)John_Betong Wrote: @pippuccio76,
> can create an entire db by visit a page ,but the answer is how can i set the db credential automatically in config->database or how can i semplify this process for user ? If i want create a csm how can user simply insert base_url and db credential without insert they in config (in config and database) ?

Check the Github link in my signature, download there zip or clone the repository and see if the installation satisfies your requirements. Please report back if you have any problems.

Why would he? It dosen't solve his problem at all...

@pippuccio76: You are using CI 3 correct? Then you need to replace that entire file with a new one using file_put_contents with settings provided during the installation.
https://www.php.net/manual/en/function.file-put-contents.php

Here you can find an example code (in PHP not Codeigniter)
https://github.com/jreklund/php4dvd/blob/master/install/index.php#L169


RE: how create an self installing project - John_Betong - 01-19-2020

(01-19-2020, 04:58 AM)jreklund Wrote: Why would he? It dosen't solve his problem at all...
Perhaps it does or does not solve the problem... I thought it did Sad

The signature links to a complete CI4 project with the Playground database populated tables with user setup, automatic login. following is a link to the Playground view:

https://ci4-strict.tk/playground

I prefer something that is working and can be modified until it breaks Smile


RE: how create an self installing project - jreklund - 01-20-2020

@John_Betong: Oh... my bad! I just looked in the app folder, and it where all empty. So I could just find declare(strict_types=1) everywhere. Didn't see the app-strict folder.

In a second glance there are some custom code. But only the import a database, nothing about saving/updating a configuration. Can you point those parts out if I'm blind again.


RE: how create an self installing project - John_Betong - 01-20-2020

(01-20-2020, 12:22 PM)jreklund Wrote: @John_Betong: Oh... my bad! I just looked in the app folder, and it where all empty. So I could just find declare(strict_types=1) everywhere. Didn't see the app-strict folder.

In a second glance there are some custom code. But only the import a database, nothing about saving/updating a configuration. Can you point those parts out if I'm blind again.

I think the installation answers the OP question as it sets the database and login requirements.

I use RSync to backup the complete project because it is remarkably fast:

https://github.com/John-Betong/ci4-strict/blob/master/app-strict/Views/pages/v-rsync.php


RE: how create an self installing project - JNapolitanoIT - 01-23-2020

Here is a pretty decent little script for you. I've modified it to use Bootstrap 4 in my own CodeIgniter 3 projects so you can easily do this too but out of turn box it works fine.

It is just a simple script that does a job of taking your input and assigning it to the database.php file. Easy and to the point.

The only thing is that this script is for CodeIgniter 3 and I highly recommend that you use CodeIgniter 4 henceforth. With a little work, you can easily modify this library to work with CodeIgniter 4 and have it write values to your .env file or your app/Config/Database.php file.

I hope this helps Smile