I am trying to delete data from database using cron job in cakephp . I have created a TestShell.php file at /app/Console/Command/TestShell.php with the following code:
<?php
class TestShell extends AppShell {
public $uses = array('BillsReceivable');
public function main() {
$this->BillsReceivable->deleteAll(array(
'BillsReceivable.days >='=>30,
));
$this->out('Records deleted..');
}
}
My cron command is:
/home/bigzip/public_html/TimeZip/app/Console/cake -app /home/bigzip/public_html/TimeZip/app TestShell
but its not working.please help.
cd /home/bigzip/public_html/TimeZip/app/
sudo Console/cake test
cakephp cron job
cd /full/path/to/app && Console/cake myshell myparam
-working defines the working directory
/home/bigzip/public_html/TimeZip/app/Console/cake.php -app /home/bigzip/public_html/TimeZip/app -working /home/bigzip/public_html/TimeZip/app TestShell
The above code should help you out
Related
When I decorate my domain class with [AdaptTo("[name]Dto"), GenerateMapper] everything works fine, but when I use:
public class MappingRegister : ICodeGenerationRegister
{
public void Register(CodeGenerationConfig config)
{
config.AdaptTo("[name]Read")
.ForType<Command>();
config.GenerateMapper("[name]Mapper")
.ForType<Command>();
}
}
it generates the same dto class as with an attribute, but the mapper class is empty:
public static partial class CommandMapper
{
}
What do I miss?
Update
So the issue that I have is not with attribute vs ICodeGenerationRegister implementation, but the fact that I have to run the build twice. The First time it generates an empty mapper class and on the second build, I get the extension methods generated.
Here is my project config
...
<Target Name="Mapster" AfterTargets="AfterBuild">
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tool restore" />
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster model -a "$(TargetDir)$(ProjectName).dll" -n Commands.Dtos -o Dtos" />
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster extension -a "$(TargetDir)$(ProjectName).dll" -n Commands.Dtos -o Dtos" />
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster mapper -a "$(TargetDir)$(ProjectName).dll" -n Commands.Dtos -o Dtos" />
</Target>
...
Mapster tool version 8.0.1
I get an error "Class does not exist" when trying to populate my DB by executing
"php artisan seed:db".
UserMoviesSeeder.php in the folder database/seeds has the following content:
<?php
use Illuminate\Database\Seeder;
use App\Project;
use App\UserMovie;
use App\User;
class UserMoviesSeeder extends Seeder
{
public function run()
{
$this->call(ProjectsTableSeeder::class);
}
}
class ProjectsTableSeeder extends Seeder {
public function run()
{
DB::table('user_movies')->delete();
DB::disableQueryLog();
UserMovie::create([
'user_id' => 1734805,
'tmdb_id' => 100,
'ratio' => 4
]);
UserMovie::create([
'user_id' => 716091,
'tmdb_id' => 100,
'ratio' => 4
]);
// ... and so on
}
}
I run the command:
php artisan db:seed --class=UserMoviesSeeder
And I get an error:
In Container.php line 752:
Class UserMoviesSeeder does not exist
I tried the following:
composer dump-autoload
It returns:
VirtualAlloc() failed: [0x00000008] ������������ ������ ��� ��������� �������.
VirtualAlloc() failed: [0x00000008] ������������ ������ ��� ��������� �������.
If I rename both, the file and the class to standard name "DatabaseSeeder" and run the command:
php artisan db:seed
Then I have an error:
Out of memory (allocated 547356672) (tried to allocate 1073741824 bytes)
I assume that 547356672 is the size of my seeder file (it is about 5.5Gb).
But why it tries to allocate twice more 1073741824 ?
I have only 8Gb of RAM, so it can't allocate 10Gb.
Previously I had 10Gb seeder in this folder, but now I have just one seeder file of 5.5Gb there.
Pardon me as this is my first questions.
I tried to install a plugin for haml in cakephp 3 manually, and found this k-motoyan/cake-haml
I can't install it using composer because I use cakephp 3.3.*
k-motoyan/cake-haml dev-master requires cakephp/cakephp 3.0.*-dev ->
no matching package found.
So, I tried to install it manually, downloading the zip and put it in [app]/plugins/kmotoyan/cakephp
I follow the readme setup
Setup
Add plugin load line to config/bootstrap.php file:
diff
+ Plugin::load('CakeHaml', ['bootstrap' => true]);
Set the default ViewClass on the src/Controller/AppController.php
file:
```diff class AppController extends Controller {
public $viewClass = 'CakeHaml\View\CakeHamlView'; ```
You can use haml on all your view files with .haml extension.
and put this code below in my config/bootstrap.php
Plugin::load('kmotoyan/CakeHaml', ['bootstrap' => true]);
and this code below in my src/Controller/AppController.php
public $viewClass = 'CakeHaml\\View\\CakeHamlView';
when I load the server, i get this error
Error: Class 'CakeHaml\View\CakeHamlView' not found File
C:\xampp\htdocs\qolega\vendor\cakephp\cakephp\src\View\ViewBuilder.php
Line: 363
when I see line 363 there's this line
return new $className($request, $response, $events, $data);
what should I do?
I'm uploading user's image in cakephp & using this code.
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
$dir = new Folder ('Upload' . DS . 'Images', true, '0755' );
when i'm debugging it is string to find Folder.php in application folder, but it exists in lib folder
Edited:
I followed the instruction in the README.md file in the directory DebugKit. But when I add this line I am getting this error above but when i comment out the line in the AppController then everything is ok and i'm getting "DebugKit plugin is present"
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $components = array('DebugKit.Toolbar');
}
does anyone know how can i smooth this error out?
I have ubuntu 14.10 CakePHP 2.5
Make sure you have
\DebugKit
\Controller
\Component
\ToolbarComponent.php
In case you don't have this directory (which was the case for me)
then
cd Plugin/DebugKit
sudo mkdir Controller
sudo mkdir Component
sudo gedit ToolbarComponent.php
And then the text editor will pop up and just put the code below
<?php
class ToolbarComponent extends Component {
}