app/Console/cake vs lib/Console/cake in CakePHP - php

I'm new to Shell using CakePHP and I couldn't notice how there are 2 cake console application: one at app/Console/cake and other in lib/Console/cake being the second one the one in CakePHP's core.
So far, I have used lib/Console/cake bake -app /path/to/app to bake some MVC classes, but I have never used app/Console/cake before. Also lib/Console/cake is configured in my environment variables.
I want to know the difference of these 2, when to use one or another and why.
Note: I moved my core folder to a different directory, so naturally, app/Console/cake wont find ShellDispatcher, which line should I modify to set the new path to core library?

Are identical, but you should use the one inside app folder:
cd app/
./Console/cake bake
To change the default folder structure and config you must edit these files:
/app/webroot/index.php
/app/webroot/test.php
and un-Comment this line putting your core folder location:
// /usr/lib/mylocation
define('CAKE_CORE_INCLUDE_PATH', DS . 'usr' . DS . 'lib' . DS . 'mylocation');
Take a look at the manual here:
http://book.cakephp.org/2.0/en/installation/advanced-installation.html#sharing-cakephp-libraries-with-multiple-applications

The difference
The difference between the two executables is that one derives the app location from the current working directory, and the other is application specific. This can be highlighted like so:
Normal usage:
www-data # dev [ /tmp/cakephp ] (master=)
-> app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
Reference app executable from different path:
-> cd anywhere
-> /tmp/cakephp/app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
Note the app and path did not change.
cake in path
If /tmp/cakephp/lib/Cake/Console/ is in the path:
-> cd anywhere
-> cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : xxx
Path: **anywhere**
---------------------------------------------------------------
Note the app and path vary depending on where you are when executing the command.
If you always specify the -app flag, they will function the same, but you'll find it is problematic to use cake in your path if for example you have multiple applications on the same host using different versions of CakePHP.
Fixing paths
If you moved the cake folder, the files you need to edit are:
app/Console/cake.php ($root variable/include_path)
app/webroot/index.php (ROOT constant)
app/webroot/test.php (ROOT constant)
Only the first will affect cli usage.

Related

Deploy Laravel 6 App on Google App Engine Standard Error: Please provide a valid cache path

I've been trying to deploy my Laravel 6 App to the standard environment of Google App Engine the whole day, but seems like I'm just stuck at how to make cache and some "local" files to work.
This is the error I get when I try to load any page:
(1/1) InvalidArgumentException
Please provide a valid cache path.
in Compiler.php line 36
at Compiler->__construct(object(Filesystem), false)
in ViewServiceProvider.php line 92
at ViewServiceProvider->Illuminate\View\{closure}(object(Application), array())
in Container.php line 799
at Container->build(object(Closure))
in Container.php line 681
at Container->resolve('blade.compiler', array(), true)
in Application.php line 785
(...)
I followed every tip at this question, this tutorial and this issue, but anything seemed to help me.
As CACHE_DRIVER, for convenience, I'm trying to just use file, instead of database or any other else. So, my app.yaml, have the additional env_variables :
CACHE_DRIVER: file
SESSION_DRIVER: cookie
APP_STORAGE: /tmp
VIEW_COMPILED_PATH: /tmp
APP_SERVICES_CACHE: /tmp/services.php
APP_PACKAGES_CACHE: /tmp/packages.php
APP_CONFIG_CACHE: /tmp/config.php
APP_ROUTES_CACHE: /tmp/routes.php
I know that the /tmp folder is the only writable folder for the App Engine Standard Environment. With that in mind, I put the above at app.yaml, and even tried renaming /storage folder to /tmp.
I've added the following line to my bootstrap/app.php file:
$app->useStoragePath(env('APP_STORAGE', base_path() . '/tmp'));
At my composer packages, I made sure that it doesn't have facade/ignition. Also, as I can't run any command after deploy my app to Google App Engine, at composer.json I have:
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
],
"post-install-cmd": [
"composer dump-autoload",
"php artisan config:clear",
"php artisan view:clear",
"php artisan cache:clear"
]
I also tried to put at post-install-cmd php artisan storage:link, while using $app->useStoragePath(env('APP_STORAGE', base_path() . '/storage')); and the /storage folder as storage itself, but nothing worked.
I have the whole folder tree for caching at my /temp (or /storage, if this is the right way) folder:
/tmp
/framework
/cache
/data
/sessions
/testing
/views
/logs
/medialibrary
/temp
Also, besides the views not rendering, I noticed that when trying to load the favicon.ico, located at /public folder, it returns an 500 error. I am new to AppEngine, but even reading everything I can find I've been struggling to make it work. I really appreciate any help.
I figured out I had some config files published at /config, and besides changing /bootstrap/app.php, some of them had their own path to /storage folder. So, my solution was just gave up on using files cache, and for the views cache, and some other packages I had, use the path /tmp, at their respective config files. Also, I removed all cache cleaning artisan commands from composer, as I wasn't sending any cache files to deploy.
Also, I needed to make some changes in order to be able to access /public files, like some local css and js. For this, I followed these docs.
I was struggling with the same problem today and the solution was I changed the 'compiled' value in config/view.php to a root folder:
Go to root directory.
mkdir compiled_views
Change 'compiled' value to 'compiled' => realpath(base_path('compiled_views/')),
I solved it by explicitly adding the APP_STORAGE env in config/view.php:
'compiled' => realpath(env('APP_STORAGE', realpath(storage_path('framework/views')))),
(which surprises because I do have $app->useStoragePath(env('APP_STORAGE', base_path() . '/storage')); added to app.php - but it seems that it didn't yet(?) override storage_path )

Using encore webpack with symfony project

I'm using the Encore/Webpack in my Symfony project, but Im having troubles with the installation.
I'm following the official guide: Link to official guide
My project folder:
projectname
---/app
---/assets
/css
/global.scss
/js
/main.js
...
---/node_modules
/.bin
/encore
...
---/web
/build
etc
I was following
Create a new file called webpack.config.js at the root of your
project.
It looks like:
projectname
...
webpack.config.js
I filled it with the example code. Afterwards I wanted to 'build' the assets with the command encore dev on path: projectname\node_modules\.bin
When I do this, I get the following error code:
Running webpack ...
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
I have no idea what I'm doing wrong. When I move the webpack.config.js to the .bin folder.. that part works, but than the build doesn't work, because it wants to install the files into .../.bin/build/ which is not correct. I want it into projectname/build like the example.
try this commend it's work for me
install webpack-notifier#^1.6.0 --save-dev

behat.yml in app/config instead of root directory

I installed behat with mink and selenium2-driver for my Symfony2 project.
Is it possible to use the /app/config/behat.yml instead of the /behat.yml file?
I searched on google but I can't find anything else this command.
php bin/behat --config app/config/behat.yml
But the command isn't working either.
I think there must be a config-path in composer.json.
Yes, you can configure which config file you want to use. Look at this part of the doc.
http://docs.behat.org/guides/7.config.html#paths
What error do you get when running your command?
php bin/behat --config app/config/behat.yml
This error?
[RuntimeException]
Context class not found.
Maybe you have provided a wrong or no `bootstrap` path in your behat.yml:
http://docs.behat.org/guides/7.config.html#paths
If that's the case, I think if might be because you need to specify where to find the features in your behat.yml file.
Now you moved the file to /app/config/behat.yml, the related path from behat.yml to the feature directory has changed, so you should add the following to the file:
default:
paths:
features: ../features/
bootstrap: ../features/bootstrap

not able to create controller from console : cakephp : showing fatal error

I am trying to create a controller in cakephp(1.3) using console. I am using windows XP and XAMPP.
My current cake console settings below
C:\xampp\htdocs\cake\apressblog\cake\console>cake
♀ Welcome to CakePHP v1.3.4 Console
--------------------------------------------------------------- Current Paths: -app: console
-working: C:\xampp\htdocs\cake\apressblog\cake\console
-root: C:\xampp\htdocs\cake\apressblog\cake
-core: C:\xampp\htdocs\cake\apressblog
Changing Paths: your working path
should be the same as your application
path to change your path use the
'-app' param. Example: -app
relative/path/to/myapp or -app
/absolute/path/to/myapp
Available Shells: acl [CORE]
i18n [CORE]
api [CORE]
schema [CORE]
bake [CORE]
testsuite [CORE]
console [CORE]
To run a command, type 'cake
shell_name [args]' To get help on a
specific command, type 'cake
shell_name help'
C:\xampp\htdocs\cake\apressblog\cake\console>-app
c:\xampp '-app' is not recognized as
an internal or external command,
operable program or batch file.
C:\xampp\htdocs\cake\apressblog\cake\console>
what are the path settings I need to set for creating a controller from console ?
I tried to change the app path but, when I type command cake It goes app directory to console,
Could you please help me to solve this issue
when I try to create a controller I am getting the following error :
C:\xampp\htdocs\cake\apressblog\cake\console>cake bake controller news
♀
Welcome to CakePHP v1.3.4 Console
---------------------------------------------------------------
App : console
Path: C:\xampp\htdocs\cake\apressblog\cake\console
---------------------------------------------------------------
Creating file C:\xampp\htdocs\cake\apressblog\cake\console\controllers\news_cont
roller.php
Wrote `C:\xampp\htdocs\cake\apressblog\cake\console\controllers\news_controller.
php`
You can download SimpleTest from http://simpletest.org
Bake is detecting possible fixtures..
Warning: include_once(C:\xampp\htdocs\cake\apressblog\cake\console\config\databa
se.php): failed to open stream: No such file or directory in C:\xampp\htdocs\cak
e\apressblog\cake\libs\model\connection_manager.php on line 23
Warning: include_once(): Failed opening 'C:\xampp\htdocs\cake\apressblog\cake\co
nsole\config\database.php' for inclusion (include_path='.;\xampp\php\PEAR') in C
:\xampp\htdocs\cake\apressblog\cake\libs\model\connection_manager.php on line 23
Fatal error: ConnectionManager::getDataSource - Non-existent data source default
in C:\xampp\htdocs\cake\apressblog\cake\libs\model\connection_manager.php on li
ne 102
C:\xampp\htdocs\cake\apressblog\cake\console>
You need to create your database.php file in the config folder so that Cake knows what database to connect to for the models.
Once you have done this you need to create your database schema and then bake the model for it.
I'd been having the same problem and was googling when I stumbled upon this. I was getting the same 'Warning: include_once...' error as you did.
I figured out this was happening only when I ran the 'cake bake' command from the ..\cake\console\ folder like you did.
So here's what fixed this issue for me. I added path to the console folder to my environment variables. Now I could call the cake bake command from anywhere.
Then I changed directory to your app folder e.g. ...\htdocs\myCakeWebsite\app
Then run 'cake bake' command! It worked fine from then on.
sources: http://www.youtube.com/watch?v=xvJH0wTlRg

cakephp console issue : not able to set path

I am trying to create a controller in cakephp(1.3) using console. I am using windows XP and XAMPP.
My current cake console settings below
C:\xampp\htdocs\cake\apressblog\cake\console>cake
♀ Welcome to CakePHP v1.3.4 Console
--------------------------------------------------------------- Current Paths: -app: console
-working: C:\xampp\htdocs\cake\apressblog\cake\console
-root: C:\xampp\htdocs\cake\apressblog\cake
-core: C:\xampp\htdocs\cake\apressblog
Changing Paths: your working path
should be the same as your application
path to change your path use the
'-app' param. Example: -app
relative/path/to/myapp or -app
/absolute/path/to/myapp
Available Shells: acl [CORE]
i18n [CORE]
api [CORE]
schema [CORE]
bake [CORE]
testsuite [CORE]
console [CORE]
To run a command, type 'cake
shell_name [args]' To get help on a
specific command, type 'cake
shell_name help'
C:\xampp\htdocs\cake\apressblog\cake\console>-app
c:\xampp '-app' is not recognized as
an internal or external command,
operable program or batch file.
C:\xampp\htdocs\cake\apressblog\cake\console>
what are the path settings I need to set for creating a controller from console ?
I tried to change the app path but, when I type command cake It goes app directory to console,
-app is a parameter for the cake command:
C:\...\console>cake -app C:\xampp\htdocs\cake\apressblog\app
You can also run cake console without problems, provided you're at the correct path. Try the following:
C:\xampp\htdocs\cake\apressblog\>C:\xampp\htdocs\cake\apressblog\cake\console\cake
or, to save yourself the trouble, add C:\xampp\htdocs\cake\apressblog\cake\console to the %PATH% environmental variable.

Categories