Welcome Guest, Not a member yet? Register   Sign In
Basic understanding of folders and structures
#1

(This post was last modified: 12-02-2024, 09:04 AM by 4usol.)

Hello. After some initial problems, I was now able to install both Codeigniter and Shield via Composer.

But I have a few basic questions because I can't really understand the following things at the moment.

1) I installed Codeigniter in a root projectfolder, then shield out of the rootfolder. A new “vendor” folder has now been created in the project folder.
What is this folder for?

2) There is now a lot in the "vendor" folder (bin/composer/fakerphp/liminas/mikey179 etc) and a "codeigniter4" folder, which is also contained there, there is now the "settings" "framework" and "shield" folder.
- Why didn't these
   
a) folders end up directly in the main project folder?

b) It seems to me that there is a complete installation of Codeigniter in the "vendort/framework" folder, in addition to the one in the main folder - why?

c) How do the folder structures behave? Until now I always thought I had a project directory, for example with the "app" folder and had all my controllers, models etc. there.

Last for the moment, what is the role of the "thisParty" folder?

Or did I simply do something wrong when installing shield? (At least running does)

Thank you!
Reply
#2

(This post was last modified: 12-02-2024, 12:20 PM by captain-sensible. Edit Reason: to edit )

well when you start from scratch and install a project using composer  eg App starter

Code:
composer create-project codeigniter4/appstarter webappDirName

will create the main dirs App, vendor, Writable and public  under webappDirName



Code:
CI4-CMS
├── Gruntfile.js
├── LICENSE
├── LICENSE-CI4-CMS
├── README-codeigniter.md
├── README.md
├── app
├── clean.sh
├── composer-bk.json
├── composer.json
├── composer.lock
├── node_modules
├── package-lock.json
├── package.json
├── preload.php
├── public
├── scss
├── spark
├── vendor
└── writable



when you then via a command line do at the context of being at the web app document root:
Code:
prompt$ composer require phpmailer/phpmailer

Then it will add the files you need for PHPMailer to Vendor; so you need that vendor file. Mess with it and things dont work

Notice in vendor there is  codeigniter4/framework/system

I'cw messed with CI4 and i found i needed that system directory and it was the only place that system existed.


However i've noticed that previously (im not sure now) that if you install with another approach you get the system directly at the level of public in the web app.If you then bring in use of composer, it sticks  files in  vendor 

by the way if you ever want to remove stuff , or reverse because you want to install another way you can do it such as :

Code:
composer remove codeigniter4/shield

With Windows 98, windows XP, i.e  different releases just like CI4   v 4.5.5  but in Windows Xp, 2000, 98 how many versions were there ? only one 

I think no matter how you install , it would be great if there was synchronicity of architecture folder structure 

So to summarize if you start with composer , and continue with composer, its all neatly tucked away in vendor.  Now the apparent "duplicate stuff" is  an update if any  on your  files in use. If they just overwrote what you had, that might wipe out  your development stuff , that you added. So basically you look in vendor and compare  against what you have, for changes, some may be breaking. Now if you use composer to install shield , then it goes to vendor/codeigniter4  directory, so still all neat and tidy .hopefully that answers some of the questions .
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#3

I understand it as "vendor" is a default folder for all installations by composer.

If i understand it in the right way, its suggested to dont make any changes in this folders to take care for future updates.

But in wich way i can customize now theese files?

For example: vendor/shield/srcs/controllers/ControllerLogin.php

Have i to copy this file, customise it an save it as new under the main folder
app/controllers/ControllerLogin.php

Have i change routes or something else, how it works?
How codeigniter knows wich file it should use?
Reply
#4

(This post was last modified: 12-07-2024, 02:36 PM by captain-sensible. Edit Reason: forgot something )

i cant help you with shield , because i wrote my own login system since my CMS was only aimed  at having one designated admin user. However i can talk about using the content  in    vendor that composer put there. my example is going to have to be  PHPMailer.  My use is "one" approach

So in vendor i have  a phpmailer directory with architecture:
Code:
[andrew@darkstar vendor]$ tree -L 2  phpmailer
phpmailer
└── phpmailer
    ├── COMMITMENT
    ├── LICENSE
    ├── README.md
    ├── SECURITY.md
    ├── VERSION
    ├── composer.json
    ├── get_oauth_token.php
    ├── language
    └── src

now the class files i use are in src which are :


Code:
[andrew@darkstar vendor]$ tree -L 2  phpmailer/phpmailer/src
phpmailer/phpmailer/src
├── DSNConfigurator.php
├── Exception.php
├── OAuth.php
├── OAuthTokenProvider.php
├── PHPMailer.php
├── POP3.php
└── SMTP.php

so in a controller which uses PHPMailer i have in the class at the beginning :

Code:
<?php

namespace App\Controllers;

use App\Controllers\BaseController;
use CodeIgniter\Controller;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;

Then in a method to  instantiate  use of class:

Code:
$mail = new PHPMailer(true);

after that its all alomg the lines of :


Code:
$mail->isSMTP();
 $mail->Timeout = 20;

$mail->SMTPDebug = 0;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;

so i would have thought you dont need to copy or move anything. Now the beauty of composer is that if a new version of PHPMailer appears , and i run from the top of my head :

Code:
composer update

then the PHPmailer in vendor gets updated .So composer is an installer and manager of sorts see :

https://getcomposer.org/

now composer has its own sort of autoloader (i think from memory) the namespace of the PHPMailer classes is:

Code:
namespace PHPMailer\PHPMailer;

so thats all i have to quote to use PHPMailer in my controller, then the class name
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#5

ok, thanks for explaining, but it doesn't give me a answear to the main question.

If i have a original file in the by composer installed folders, how can i change for example a controller for my own project without changing the original file?

PS: Maybe sorry for my english ;-)
Reply
#6

you mean like :

Code:
class myCustomClass   extends OriginalClass
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#7

Always read the documentation first. Almost all answers have already been resolved.
https://shield.codeigniter.com/customiza...ntrollers/
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#8

ok thanks!!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB