Basic understanding of folders and structures |
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!
12-02-2024, 11:20 AM
(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 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 .
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?
12-07-2024, 02:19 PM
(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 now the class files i use are in src which are : Code: [andrew@darkstar vendor]$ tree -L 2 phpmailer/phpmailer/src so in a controller which uses PHPMailer i have in the class at the beginning : Code: <?php 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(); 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
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 ;-)
Always read the documentation first. Almost all answers have already been resolved.
https://shield.codeigniter.com/customiza...ntrollers/
|
Welcome Guest, Not a member yet? Register Sign In |