Welcome Guest, Not a member yet? Register   Sign In
how to get limited number of records and order by rand ?
#4

(This post was last modified: 11-07-2020, 05:57 AM by captain-sensible.)

ok there is a handy site for software that you can get via composer : https://packagist.org/

lets say you want to allow people to download the text version of a blog you have. So i enter html2pdf in search box of packagist : Top of the list i see :

spipu/html2pdf

i left click on it and then see:

composer require spipu/html2pdf

thats tells me that if i have composer set up correctly , i open a terminal and cd to root directory of web dev

and run:

Code:
composer require spipu/html2pdf
//or maybe php composer.phar require spipu/html2pdf

i then see in vendor directory: spipu

and also notice a chnage in composer.json

Code:
"spipu/html2pdf": "^5.2",
//above has been added

some software obtained via composer have deps , and to make sure you have them, just run after running
Code:
composer require spipu/html2pdf

composer install

A few things to note here. If your using appstarter, vendor directory is where stuff goes and thus is critical to keep. System directory if its there is more for ref as far as i can see.

Once you have software , its now easy when you need to update.

For instance ig a new version of codeigniter appears you can run

Code:
composer update codeigniter4/framework

to avoid getting dev you can use --no-dev


oh one more thing, composer has autoload so it knows where the software is :


to use for example spipu in a controller i found all i had to do was put at top of controller:

Code:
use Spipu\Html2Pdf\Html2Pdf;
and then in method:

Code:
$html2pdf = new Html2Pdf();
$html2pdf->writeHTML("<h3>".$mytitle."</h3>".$mystring);
ob_end_clean();
$html2pdf->output($mytitle.'.pdf', 'D');



if you manually set something up not using composer then you have to use the autoloader of CI4 which is : app/Config/Autoload.php

if it has a namespace use $psr4 = [

]

if not there is a class map section below that .That should be enough to get you going ?
Reply


Messages In This Thread
RE: how to get limited number of records and order by rand ? - by captain-sensible - 11-07-2020, 05:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB