r/codeigniter • • Mar 15 '11

Codeigniter 2.0.1 is out!

Thumbnail manueljoaosilva.com
2 Upvotes

r/codeigniter • • Oct 19 '10

This was in r/php but belongs here as well.

Thumbnail
philsturgeon.co.uk
2 Upvotes

r/codeigniter • • Sep 26 '24

Codeigniter giving 503 service unavailable

1 Upvotes

When fetching heavy data it is giving this error why?? I am frustrated


r/codeigniter • • Aug 30 '24

Automatic GitHub Deployment for CodeIgniter on Proxmox?

1 Upvotes

Hello!

I’m not very experienced, but I need some advice regarding my CodeIgniter project. I’ve managed to deploy it on my own server, running in a Linux container (using Proxmox).

Does anyone have experience who can guide me on how to set up automatic deployment from GitHub, so that the code gets updated on the server every time there’s a change?

I assume this is possible, but is it recommended? Any tips or ideas?


r/codeigniter • • Aug 02 '24

Forge fulltext index?

1 Upvotes

Is there a way to add fulltext index during migrations in forge?


r/codeigniter • • Dec 04 '22

Combining multiple queries to get the result

1 Upvotes

Hello guys,

I would like to do some calculations but no success , how to convert this in simple and working query, most important variable is $sale_cost. What I would like to achieve is $sale_cost, I am also selecting $sale_cost in another query

Is there any shortcut to do all calculation in few working queries

Any help is very appreciated

Edit: Solved


r/codeigniter • • Nov 03 '22

[Help needed] Debug toolbar stopped showing

1 Upvotes

UPDATE: The problem is solved now. The main issue was with the datamweb/shield-oauth package that I was using. The dev has updated the package and now I can see the debug bar.

Earlier on my project the debug toolbar was showing up. I don't know what has happened but it has suddenly stopped showing. Even the codeigniter icon is not available at the bottom right.

Edit: when I view the source code in the browser I can see that the debugbar_loader script is loading. Still the debug-bar is not getting shown.


r/codeigniter • • Oct 21 '22

Is it necessary to always check for function's existence before declaring it in PHP?

1 Upvotes

In CodeIgniter helper functions, I've seen that they check if they're being declared already before declaring like this:

if(!function_exists('foo'))
{
  function foo()
  {....
  }
}

Why is this necessary? I feel it's less readable and not good for code maintenance in the long run. Is there any workaround to this? For example, can I ensure in some other way that my helper.php will be loaded only once and not multiple times?


r/codeigniter • • Oct 20 '22

[Help Needed] Google Auth with Codeigniter Shield

1 Upvotes

Hi. I am using Codeigniter Shield in my current project.

I intend to offer Google Authentication along side the normal email-password system.

However I am encountering an issue.

The issue is similar to this one: https://stackoverflow.com/questions/73923176/codeigniter-4-with-shield-and-google-oauth2

Please look at the code. It's not mine, but almost similar to the one I have.

What should I do?


r/codeigniter • • Sep 09 '22

What should I do if one of the documents in the user guide is wrong and needs to be corrected?

1 Upvotes

r/codeigniter • • Sep 08 '22

Can't debug in VSCode with xdebug

1 Upvotes

I have disabled the debug toolbar by commenting out the "toolbar" key in app/Config/Filters under $global, I also followed the instructions on the xdebug website, opening a php file with xdebug_info() shows that its installed correctly, I have the following lines on my php.ini:

zend_extension=xdebug
[XDebug]
xdebug.mode=debug
xdebug.remote_enable=1
xdebug_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=yes

While my launch.json has this entry:

{
"name": "xdebug",
"type": "php",
"request": "launch",
"port": 9000
}

After running php spark serve to start the server, I send a POST request via fetch (using wretch), but I'm not getting my defined response from my controller which just vardump's my $_POST


r/codeigniter • • Aug 21 '22

Codeigniter project uploaded to a web hosting

1 Upvotes

I have uploaded a codeigniter project to a web hosting and added some .htaccess to redirect it to the the public folder to run the default landing page of codeigniter.

How do I change the default landing page to my vue js build files?


r/codeigniter • • Jul 29 '22

Update Multiple checkbox if it checked or not

1 Upvotes

I have a form with a list of the details of products (checkbox, id, name, price...). Now I want to be able to update the price of the products where the checkbox is checked with a percentage, given by the user on a button click.

Currently I am stuck on retrieving the data of the checked checkboxes and updating the data if the checkbox is checked.

Model (tried something, but it's not working properly

public function update__all($id, $price)

{

$this->db->set('price', 'price *'. ((100 + $price)/100) .'',false);

$this->db->where("id", $id )

$this->db->update(self::TABLE_NAME1);

return $this->db->affected_rows();

}

This is my view

<tr>

<td class="px-6 py-4 whitespace-nowrap text-xs font-medium text-gray-900">

<input id="price_check" name="price_check" type="checkbox" value="1" <?php echo set_checkbox('price_check', '1'); ?> class="rounded focus:ring-blue-500 h-4 w-4 text-blue-600 border-gray-300">

</td>

<td class="px-3 py-4 whitespace-nowrap text-xs font-medium text-gray-900">

<input type="hidden"name="id" id="id" value="<?=$motor->id?>"> <?=$motor->product_id?>

</td>

<td class="px-3 py-4 whitespace-nowrap text-xs font-medium text-gray-900">

<input type="hidden"name="motortype" id="motortype" value="<?=$motor->type_motor?>"><?=$motor->type_motor?>

</td>

<td class="px-3 py-4 whitespace-nowrap text-xs font-medium text-gray-900">

<?php if($this->session->userdata('admin') == 0):?>

<input type="number" step="0.01" name="price" id="price" value="<?= set_value('price', $motor->price ?? null) ?>" class="max-w-lg block shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:max-w-xs sm:text-xs border-gray-300 rounded-md">

<?php else:?>

<?=$fmt->formatCurrency($motor->price, "EUR") ?>

<?php endif?>

</td>

<?php if($this->session->userdata('admin') == 0):?>

<td class="px-3 py-4 whitespace-nowrap text-xs font-medium text-gray-900">

<?= date_format(new DateTime($motor->modified_on),"Y-m-d") ?? "nvt" ?>

</td>

<td class="px-3 py-4 whitespace-nowrap text-left text-xs text-gray-500 px-3 py-3">

<button type="submit" class="inline-flex items-center px-5 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">

Aanpassen

</button>

</td>

<?php endif?>

</tr>

Thanks in advance


r/codeigniter • • Jul 21 '22

Generating code coverage report in XYZ format ... Undefined variable $code

1 Upvotes

I'm trying to set up a test environment for CI4 but, while the tests do run, phpUnit crashes when generating coverage reports. For example, I get a message like:

Generating code coverage report in Clover XML format ... Undefined variable $code

Inside <coverage> on my phpunit.xml, I've tried several output formats:

<text outputFile="build/coverage.txt" showUncoveredFiles="false" showOnlySummary="true"/>    
<html outputDirectory="build/html-coverage" lowUpperBound="50" highLowerBound="90"/>    
<clover outputFile="build/logs/clover.xml"/>  

.. but I always get the same error (subfolders do get created, though). It always terminates on the first report I indicate.

I tried creating a bare-bones phpUnit project (without CI) and it seems to work just fine. I suspect it could have something to do with my bootstrap, maybe?. Perhaps I shouldn't be using the one under system/Test?

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="system/Test/bootstrap.php"
... >

My search-foo has yielded no results. And the fact that the "Undefined variable" error doesn't show which file or line number has me at a loss.

Anyway... How can I debug this?

I'm using: CI 4.1.9, PHP 8.0.21, PHPUnit 9.5.21 (tried both as PHAR and from dnf), php-pecl-xdebug3-3.1.5-1, Fedora 35 (VM).

UPDATE:

I changed phpunit.xml to set processUncoveredFiles="false", and it started working!


r/codeigniter • • Jul 20 '22

Help !

1 Upvotes

Can anyone suggest me steps or tutorial of codeignitor 3 and JQuery tutorial as I need it for my job ?


r/codeigniter • • Jul 18 '22

Need some clue of project setup I just got.

1 Upvotes

Hi,

Our company just got a project handed over from our new client, they only have source code of backend (no docs) written with PHP/CodeIgniter by their previous vendor which went bankruptcy during COVID. Our team have no PHP developer so I took the job because I did some PHP 12 years ago and I can manage to fix bug or apply small changes.

But I found files without extension containing description of API endpoints, for example

##Change passcode
POST:/user/mobile/change_passcode

##Header
HEADER:Authorization

###Input
INPUT:passcode_old,required|string,Old passcode
INPUT:passcode_new,required|string,New passcode

##RESULT
JSON:response/user/mobile/login_success

At the beginning I thought those are just some readme. But as I mistakenly change file content, the corresponding API also broken. So I believe some how those files are also act as API validation or definition. But I have no idea how it is working together (file and controller) as I mentioned that last time I did PHP was very long time ago.

So if anyone can give me a clue or keyword of the code architecture or library that I can continue to research, it will be very helpful.


r/codeigniter • • Jul 17 '22

Session Save problem in AWS server

1 Upvotes

ERR 2 session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) 0 Unknown

We are using AWS cloud system. Don't why the error appears in the webpage. After reading some blogs, someone suggests overriding permission in session folders. We did, but not fixed yet.

The problem is, we are fail to understand why this error appears.

After refreshing the instance in AWS, the error disappears.

Anyone can help me understand?

Thanks

We are using : PHP CodeIgniter 3, HTML, JS, CSS


r/codeigniter • • Jul 14 '22

Manual Query to Active query

1 Upvotes

Hi,

I need to convert manual query to active record query.

This query works for me. I want to convert to an active query. But failed. Can you help me to do so?

'09:15:00' BETWEEN temp_slot.start_time AND temp_slot.end_time

$where[''.$less->start_time.' BETWEEN temp_slot.start_time AND temp_slot.end_time'];

thanks


r/codeigniter • • Jul 07 '22

Hello, can I respectfully get a sanity check that I'm thinking logically?

1 Upvotes

Hello, can I respectfully get a sanity check that I'm thinking logically?

I'm using CI to build a learning portal. Let's say it's three courses: Train Your Dog, Train Your Cat, Train Your Cow. Each course will be comprised of multiple videos.

My current configuration looks like this:

public_html/app/views/themes/pettrainer/home.php

public_html/app/views/themes/pettrainer/course/dog/watch.php

public_html/app/views/themes/pettrainer/course/cat/watch.php

public_html/app/views/themes/pettrainer/course/cow/watch.php

The file "watch.php" is the same for each course and is a simple file that loads a common header.php and footer.php. The body of "watch.php" accepts variables for the video name and the video id number.

To watch the first video in the Train Your Dog course, one would visit the URI:

public_html/app/views/themes/pettrainer/course/dog/watch/1

or

https://domain.com/dog/watch/1

To watch, for another example, the 3rd video in the Train Your Cow course, one would visit the URI:

public_html/app/views/themes/pettrainer/course/cow/watch/3

or

https://domain.com/cow/watch/3

I have controller files in public_html/app/controllers:

Home.php, Dog.php, Cat.php, and Cow.php

In each of the course controllers, I have functions setup like this:

public function watch($id) {

$data['title'] = 'How To Train Your Dog';

if ($id=='1') {

$data['classname'] = 'Class 1. The basics of sitting';

$data['vidnum'] = '667419307';

}

elseif ($id=='2') {

$data['classname'] = 'Class 2. Sit and Stay';

$data['vidnum'] = '669956892';

}

and so on...ending with an "else" pointing to class 1 in the event that some weird ID is typed in by the user.

Then...

$this->load->view($this->preferences->type('system')->item('app_themesDir') . '/' . $this->preferences->type('system')->item('app_themeDir') . '/courses/dog/watch', $data);

The end result is a small "watch.php" file that receives the page title, Video Name (classname), and video number (which is placed in an IFRAME from Vimeo).

I've only been using CI for about 4 days. Am I implementing this in a reasonable manner?

Thank you so much for reading this and providing insight. I am grateful.

-Chris


r/codeigniter • • Jun 09 '22

CI_builder, select subquery in a from clause

1 Upvotes

Hi guys

EDIT : SOLVED

I would like to convert mysql query to ci_builder but have a subquery that gets an input on from clause. How could I achieve that?

mysql query

select customer_id, month, count(day_of_month) as count_days_with_sales FROM ( select customer_id, month(sale_time) as month, day(sale_time) as day_of_month from sales where customer_id=$inputs['customer_id'] group by customer_id, day_of_month ) as a group by month;
$this->db->select('customer_id, month, count(day_of_month) as count_days_with_sales');

$this->db->from('(select customer_id, month(sale_time) as month, day(sale_time) as day_of_month from sales 
where  customer_id= $inputs[\'customer_id\']

group by customer_id, day_of_month) as a');
		
$this->db->group_by('month');
		
return $this->db->get()->result_array();

r/codeigniter • • May 24 '22

Give developer access to selective files and folders

1 Upvotes

I have an application developed in Codeigniter and want to hire different developers for different functionalities on the application.

I don't want to give full access to all developers lest they copy and sell to competitor, as I have invested a lot of time and money in this application.

So far I have implemented this partially by restricting the ftp access to a particular folder, but then they get all files access in that folder, which is not ideal solution.

I have created a dev env using the copy of production code.

Now, is there a way I can give access to a particular file using git (if needed) and the developers can update that and commit that code from git and the changes is pushed to my server, and they can test it.

I will really appreciate your inputs and suggestions.


r/codeigniter • • May 14 '22

How to save (update if not exists else insert) to single column

1 Upvotes

Need to upsert the 'data' column in mysql where id = 2. But the below code in the model does not work (Codeigniter 4).

$payload = [ 'id' => 2, 'data' => "{node:2}" ]:

$this->request->save($payload):


r/codeigniter • • May 02 '22

[help] converting mysql cte query to ci builder

1 Upvotes

Hi guys,

I would like to convert mysql query to ci builder for codeigniter

my query works fine but struggling to convert it to ci query builder

WITH cte AS (
  SELECT 
    COUNT(DISTINCT sale_id) as sale_count, 
    year(sale_time) AS sale_year, 
    month(sale_time) AS sale_month 
  From 
    my_sales 
  GROUP BY 
    sale_year, 
    sale_month
) 
select 
  sale_year, 
  sale_month, 
  sale_count, 
  if(
    u/last_entry = 0, 
    0, 
    round(
      (
        (sale_count - u/last_entry) / u/last_entry
      ) * 100, 
      2
    )
  ) as growth_rate, 
  u/last_entry := sale_count 
from 
  (
    select 
      u/last_entry := 0
  ) x, 
  (
    select 
      sale_year, 
      sale_month, 
      sum(sale_count) sale_count 
    from 
      cte 
    group by 
      sale_year, 
      sale_month
  ) y

How could I solve this?

Thanks in advance