Welcome Guest, Not a member yet? Register   Sign In
CI4 clone folder inside Vendor!?
#1
Sad 

Hi all, I'm moving from CI3 to CI4, and I also decided to use Composer to create and manage new projects instead of the old (good) way of downloading a .zip with the boilerplate of the framework.

The app works fine, and I am getting used to the changes, however I was wondering if it is normal that inside Vendor there are a lot of dependencies which I have never heard about (i.e. nikic, sebastian, ...) and, also, is it normal that there is a Codeigniter4 clone folder inside Vendor that contains again all the structure of the framework?

I attached a screenshot and below you can find the weird file structure:
Code:
C:.
├───app
│  ├───Config
│  │  └───Boot
│  ├───Controllers
│  ├───Database
│  │  ├───Migrations
│  │  └───Seeds
│  ├───Filters
│  ├───Helpers
│  ├───Language
│  │  └───en
│  ├───Libraries
│  ├───Models
│  ├───ThirdParty
│  └───Views
│      └───errors
│          ├───cli
│          └───html
├───public
├───tests
│  ├───database
│  ├───session
│  ├───unit
│  └───_support
│      ├───Database
│      │  ├───Migrations
│      │  └───Seeds
│      ├───Libraries
│      └───Models
├───vendor
│  ├───bin
│  ├───codeigniter4
│  │  └───framework
│  │      ├───app
│  │      │  ├───Config
│  │      │  │  └───Boot
│  │      │  ├───Controllers
│  │      │  ├───Database
│  │      │  │  ├───Migrations
│  │      │  │  └───Seeds
│  │      │  ├───Filters
│  │      │  ├───Helpers
│  │      │  ├───Language
│  │      │  │  └───en
│  │      │  ├───Libraries
│  │      │  ├───Models
│  │      │  ├───ThirdParty
│  │      │  └───Views
│  │      │      └───errors
│  │      │          ├───cli
│  │      │          └───html
│  │      ├───public
│  │      ├───system
│  │      │  ├───API
│  │      │  ├───Autoloader
│  │      │  ├───Cache
│  │      │  │  ├───Exceptions
│  │      │  │  └───Handlers
│  │      │  ├───CLI
│  │      │  │  └───Exceptions
│  │      │  ├───Commands
│  │      │  │  ├───Cache
│  │      │  │  ├───Database
│  │      │  │  ├───Encryption
│  │      │  │  ├───Generators
│  │      │  │  │  └───Views
│  │      │  │  ├───Housekeeping
│  │      │  │  ├───Server
│  │      │  │  └───Utilities
│  │      │  ├───Config
│  │      │  ├───Cookie
│  │      │  │  └───Exceptions
│  │      │  ├───Database
│  │      │  │  ├───Exceptions
│  │      │  │  ├───MySQLi
│  │      │  │  ├───Postgre
│  │      │  │  ├───SQLite3
│  │      │  │  └───SQLSRV
│  │      │  ├───Debug
│  │      │  │  └───Toolbar
│  │      │  │      ├───Collectors
│  │      │  │      └───Views
│  │      │  ├───Email
│  │      │  ├───Encryption
│  │      │  │  ├───Exceptions
│  │      │  │  └───Handlers
│  │      │  ├───Entity
│  │      │  │  ├───Cast
│  │      │  │  └───Exceptions
│  │      │  ├───Events
│  │      │  ├───Exceptions
│  │      │  ├───Files
│  │      │  │  └───Exceptions
│  │      │  ├───Filters
│  │      │  │  └───Exceptions
│  │      │  ├───Format
│  │      │  │  └───Exceptions
│  │      │  ├───Helpers
│  │      │  ├───Honeypot
│  │      │  │  └───Exceptions
│  │      │  ├───HTTP
│  │      │  │  ├───Exceptions
│  │      │  │  └───Files
│  │      │  ├───I18n
│  │      │  │  └───Exceptions
│  │      │  ├───Images
│  │      │  │  ├───Exceptions
│  │      │  │  └───Handlers
│  │      │  ├───Language
│  │      │  │  └───en
│  │      │  ├───Log
│  │      │  │  ├───Exceptions
│  │      │  │  └───Handlers
│  │      │  ├───Modules
│  │      │  ├───Pager
│  │      │  │  ├───Exceptions
│  │      │  │  └───Views
│  │      │  ├───RESTful
│  │      │  ├───Router
│  │      │  │  └───Exceptions
│  │      │  ├───Security
│  │      │  │  └───Exceptions
│  │      │  ├───Session
│  │      │  │  ├───Exceptions
│  │      │  │  └───Handlers
│  │      │  ├───Test
│  │      │  │  ├───Constraints
│  │      │  │  ├───Filters
│  │      │  │  ├───Interfaces
│  │      │  │  └───Mock
│  │      │  ├───ThirdParty
│  │      │  │  ├───Escaper
│  │      │  │  │  └───Exception
│  │      │  │  ├───Kint
│  │      │  │  │  ├───Object
│  │      │  │  │  │  └───Representation
│  │      │  │  │  ├───Parser
│  │      │  │  │  ├───Renderer
│  │      │  │  │  │  ├───Rich
│  │      │  │  │  │  └───Text
│  │      │  │  │  └───resources
│  │      │  │  │      └───compiled
│  │      │  │  └───PSR
│  │      │  │      └───Log
│  │      │  ├───Throttle
│  │      │  ├───Typography
│  │      │  ├───Validation
│  │      │  │  ├───Exceptions
│  │      │  │  └───Views
│  │      │  └───View
│  │      │      └───Exceptions
│  │      └───writable
│  │          ├───cache
│  │          ├───debugbar
│  │          ├───logs
│  │          ├───session
│  │          └───uploads


Attached Files Thumbnail(s)
   
Reply
#2

Dont move or change vendor folder
Enlightenment  Is  Freedom
Reply
#3

By default, Composer will install ALL dependencies defined in your composer.json file. So all production dependencies (those in "require") and development dependencies (those in "require-dev") will be installed. If you do not want to install those dev dependencies, you can reset the installation.
Code:
# in the root of your project run the following:
rm -rf vendor
rm -rf composer.lock
composer update --no-dev

Now, your project will only have the prod dependencies installed. If in the future you want to update to the latest version of the framework, you just need to run "composer update --no-dev" again in your terminal. Don't forget to always include the "--no-dev" flag to always ensure dev dependencies are not installed with the update.

Now, on the topic of duplicated folder structure in the vendor folder. It is there for a reason.
1. The main framework logic is found in "vendor/codeigniter4/framework/system/".
2. The other folders which are clearly duplicates of your project in the root directory should not be touched. Why? It serves as your backup. In case you messed something for example in the "app/Config", you can just copy the "pure" version in the vendor.
3. Another one is when you update versions of the framework, your version of files may not be updated anymore with the latest changes. For example, in the latest release a new config file was added "app/Config/Foo.php" but your project does not have that copy yet in the project root. So your solution is to simply copy that new file into your project. Another, let's say "app/Config/App.php" got a new config property added. Your copy is not updated so you can simply copy from there.
Reply
#4

Awesome, Crystal clear, thanks a ton you all! Especially to Paul for the great explanation!
Mauro
Reply
#5

Must be a related question...

when I copy the app to the production server, I do not want to copy all the development dependencies in "vendor", so I only copy codeigniter, benedmunds and composer. However, if I do not include other stuff in "vendor", I get fatal error about missing phpunit. If I upload only the phpunit, I get fatal error about missing symphony:

Code:
Fatal error: require(): Failed opening required '/home/me/domains/mysite.lt/myproject/vendor/composer/../symfony/polyfill-ctype/bootstrap.php' (include_path='.:/usr/share/pear') in '/home/me/domains/mysite.lt/myproject/vendor/composer/autoload_real.php on line 71

How do I tell the system that I do not want all those dependencies I do not use in the production?
==

Donatas G.
Reply
#6

In your dev copy, your vendor/composer files have links also to the dev dependencies of your project. So, if you just copy files around, those vendor/composer files's contents are still linked to the old dev files. Thus, when you fire up your server, it will look for those files in your prod server but are actually missing, causing the error.

Solution is to use the steps I provided above: using composer update et al.
Reply
#7

(This post was last modified: 09-18-2021, 09:28 AM by dgvirtual.)

[quote pid="390106" dateline="1631969689"]Solution is to use the steps I provided above: using composer update et al. [/quote]
Thank you for the explanation. It is not yet clear to me how to manage the production site update from the local dev environment (it kind of becomes cumbersome, unless I keep a different directory just for the proper --no-dev updates), but I did as you suggested and it worked. Thanks!
==

Donatas G.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB